Bug 251025

Summary: [REGRESSION] kompare: setting tabwidth to anything < 4 shows only the first level of indentation
Product: [Applications] kompare Reporter: esigra
Component: viewpartAssignee: Kompare developers <kompare-devel>
Status: RESOLVED FIXED    
Severity: normal CC: dilfridge, esigra, johu
Priority: NOR    
Version: 4.0.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: KDE SC 4.8.1 / Kompare 4.1.1

Description esigra 2010-09-12 22:50:17 UTC
Version:           4.0.0 (using KDE 4.5.1) 
OS:                Linux

When the tabwidth is set to any value < 4, lines with > 1 level of indentation are shown with only 1 level of indentation. Therefore only lines with 0 or 1 level of indentation are shown correctly. It seems to work with tab widths >= 4.

Reproducible: Always

Steps to Reproduce:
1. Start Konsole.
2. Create a directory and cd into it.
3. Create the empty file empty.cc
4. Create the file prov.cc with some content like this:
float calculate_something(float const a, float const b, float const c) {
   return
      calculate_something(1.7, calculate_something(8.9, 19.51, 33.0), a) +
      calculate_something(c, 18.8, calculate_something(7.5, b, a));
}
5. Execute "diff -u empty.cc prov.cc|kompare -".
6. Open the settings dialog and change the tab width to 3.
7. Press Ok.

Actual Results:  
float calculate_something(float const a, float const b, float const c) {
   return
   calculate_something(1.7, calculate_something(8.9, 19.51, 33.0), a) +
   calculate_something(c, 18.8, calculate_something(7.5, b, a));
}

Expected Results:  
float calculate_something(float const a, float const b, float const c) {
   return
      calculate_something(1.7, calculate_something(8.9, 19.51, 33.0), a) +
      calculate_something(c, 18.8, calculate_something(7.5, b, a));
}

This problem is new in KDE4.
Comment 1 Johannes Huber 2012-02-08 19:19:04 UTC
Ping
Comment 2 Kevin Kofler 2012-02-09 00:19:01 UTC
Hmmm, the KompareListViewLineItem::expandTabs routine uses the following formula:
QString(tabstop-((startPos+index)%4),' ')
which looks very wrong to me. The hardcoded "4" does not make any sense whatsoever. The regression was introduced by this commit:
http://websvn.kde.org/?view=revision&revision=1026032
by je4d.
Comment 3 Kevin Kofler 2012-02-09 00:20:27 UTC
The correct formula is:
QString(tabstop-((startPos+index)%tabstop),' ')
Comment 4 Kevin Kofler 2012-02-09 00:29:24 UTC
SVN commit 1278831 by kkofler:

Kompare: Fix nonsensical tab expansion formula introduced by commit 1026032.

FIXED-IN: 4.8.1

 M  +1 -1      komparelistview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1278831
Comment 5 Kevin Kofler 2012-02-09 00:35:25 UTC
SVN commit 1278833 by kkofler:

Kompare: Fix nonsensical tab expansion formula introduced by commit 1026032.

Backport revision 1278831 from trunk.

 M  +1 -1      komparelistview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1278833
Comment 6 Johannes Huber 2012-02-09 06:48:58 UTC
Thank you!