Bug 145956 - Kompare displays wrong line numbers in target file after applying a change
Summary: Kompare displays wrong line numbers in target file after applying a change
Status: REOPENED
Alias: None
Product: kompare
Classification: Applications
Component: general (show other bugs)
Version: 4.1.2
Platform: Chakra Linux
: NOR normal
Target Milestone: ---
Assignee: Kompare developers
URL:
Keywords: reproducible
Depends on:
Blocks:
 
Reported: 2007-05-25 16:07 UTC by Olivier Vitrat
Modified: 2013-01-16 19:56 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Vitrat 2007-05-25 16:07:49 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Debian stable Packages

Reported in Debian BTS at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=364881

Create two example files to reproduce the bug:

a.txt:

1a
2a
- new line inserted here -
- new line inserted here -
- new line inserted here -
- new line inserted here -
3a
4a
5a - modified -
6a - modified -
7a - modified -
8a

b.txt:

1a
2a
3a
4a
5a
6a
7a
8a

Then compare them: kompare a.txt b.txt
Apply the first difference (inserted lines).
Line numbers will be wrong in the target file.
Apply the second difference (modified lines).
Line numbers of modified lines will be copied
from the source file (a.txt). This behaviour
causes very strange line numbering in the target
file.

This bug is usually harmless, but causes problems
when you try to remember positions by target line
numbers to be able to do changes later. You will
easily write down wrong line numbers and will not
be able to locate these positions in the merged
target file in the source code editor later.
This is especially flustrating when merging fixes
between code bases of similar applications.

In my opinion, kompare should renumber target lines
after applying each difference from the source file
and ensure that line numbers are continuous as usual.
The difference graphics will show the source of such
lines, so copying source line numbers is rather a
wrong idea than a feature.
Comment 1 FiNeX 2009-01-04 16:49:50 UTC
I've reproduced using KDE 4 version of kompare (trunk, r905373)
Comment 2 Otto Bruggeman 2009-02-14 16:59:47 UTC
Should not be too difficult. Assigning to myself.
Comment 3 Otto Bruggeman 2009-02-14 18:53:36 UTC
SVN commit 926131 by bruggie:

BUG: 145956 It was easier than expected. Fixed linenumbers in destination after applying.

 M  +25 -0     komparelistview.cpp  
 M  +13 -4     komparelistview.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=926131
Comment 4 Kevin Kofler 2009-02-19 01:17:53 UTC
SVN commit 928150 by kkofler:

Mass backport of Kompare bugfixes for KDE 4.2.1 (should not touch any translatable strings): backport revisions 913308, 913309, 922431 (Kompare only), 924527, 924539, 924540, 924880, 924959, 924960, 925266, 926028, 926131, 926143, 926225, 928082 (minus i18n string changes), 928141, 928146 from trunk.
CCBUG: 176804
CCBUG: 169692
CCBUG: 182792
CCBUG: 176797
CCBUG: 175251
CCBUG: 75794
CCBUG: 89781
CCBUG: 145956
CCBUG: 107489
CCBUG: 165421
CCBUG: 174924
CCBUG: 103651
CCBUG: 102800
CCMAIL: bruggie@gmail.com

Bump Kompare version from 3.5.2 to 3.5.3 (trunk is 4.0.0).

Tested on Fedora 9 i386, KDE 4.2.0.

Note: skipped revision 926198 because it introduces a string and #124121 is more a user error than a bug anyway.

 M  +34 -30    kompare_shell.cpp  
 M  +18 -3     komparenavtreepart/komparenavtreepart.cpp  
 M  +15 -12    komparepart/kompare_part.cpp  
 M  +2 -2      komparepart/kompare_part.h  
 M  +9 -6      komparepart/kompareconnectwidget.cpp  
 M  +80 -31    komparepart/komparelistview.cpp  
 M  +26 -5     komparepart/komparelistview.h  
 M  +2 -2      komparepart/kompareprefdlg.cpp  
 M  +4 -1      komparepart/kompareprefdlg.h  
 M  +1 -1      komparepart/komparesplitter.cpp  
 M  +2 -1      libdialogpages/diffpage.cpp  
 M  +4 -3      libdialogpages/diffpage.h  
 M  +14 -4     libdialogpages/filespage.cpp  
 M  +4 -4      libdialogpages/filespage.h  
 M  +10 -8     libdiff2/difference.cpp  
 M  +5 -2      libdiff2/difference.h  
 M  +2 -1      libdiff2/diffhunk.cpp  
 M  +2 -2      libdiff2/diffhunk.h  
 M  +5 -30     libdiff2/diffmodel.cpp  
 M  +3 -6      libdiff2/diffmodel.h  
 M  +1 -1      libdiff2/diffmodellist.cpp  
 M  +4 -2      libdiff2/diffmodellist.h  
 M  +34 -31    libdiff2/komparemodellist.cpp  
 M  +3 -1      libdiff2/komparemodellist.h  
 M  +2 -1      libdiff2/kompareprocess.cpp  
 M  +53 -17    libdiff2/levenshteintable.cpp  
 M  +5 -1      libdiff2/parserbase.cpp  
 M  +21 -26    main.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=928150
Comment 5 Otto Bruggeman 2009-02-20 00:46:48 UTC
Not fixed for just viewing diffs like with "svn diff | kompare -", need to fix this there as well, maybe just not renumber the lines here because that is the best solution.
Comment 6 Adrián Chaves (Gallaecio) 2012-10-30 20:46:16 UTC
I can confirm the bug. The steps I followed were those mentioned here, opening Kompare like this:

diff -Naur a.txt b.txt | kompare -