Version: (using KDE KDE 3.3.1) Installed from: Gentoo Packages Compiler: gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6) OS: Linux Open Kate or open a new window in kate. Enter some empty lines and go in in the middle of these lines so cursor up could work. B-) Enter some text (without spaces) like: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Press <TAB> Enter some text (without spaces) in the same line until the last part wraps around. So your screen looks like this: 1 2 3 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 4 5 1) Your cursor should be at the last 'a' of the second line. Press 'cursor up'. The cursor jumps to the first 'a' in the second line. Press 'up' again. With my kate nothing happens here but shouldn't the cursor goes to line 2? You can leave the line and reproduce this 'feature'. 2) Click on the last 'a' in the second row. Go down a few times and go up again. Stuck. 3) Click on the first 'a' in the first row. Go down a few times and go up again. It's working. It think the bug is related to the fact the kate tries to remember the 'wish-x-coordinate' for the cursor.
This bug works for 'kwrite' too. I think both are using the same editor components...
I can confirm this using cvs HEAD (the upcoming Kate 2.4) It's depending on the actual width of the tab, it must be at least two characters I think. So somewhere the width is calculated pr character instead of the real width.
Still valid.
*** Bug 130201 has been marked as a duplicate of this bug. ***
*** Bug 142361 has been marked as a duplicate of this bug. ***
Created attachment 20703 [details] Fixed
Created attachment 20705 [details] A patch for this bug, second version My previous patch only worked when there was only one tab on the wrapped line. This version also works on lines with multiple tabs.
SVN commit 668824 by dhaumann: fix: tabs in wrapped line broke cursor navigation Is there a better/faster way? - todo: forward port Thanks to Ruud Koolen for the patch! CCMAIL: kwrite-devel@kde.org BUG: 94693 M +5 -5 katerenderer.cpp M +16 -1 kateviewinternal.cpp --- branches/KDE/3.5/kdelibs/kate/part/katerenderer.cpp #668823:668824 @@ -798,6 +798,11 @@ Q_ASSERT(width); x += width; + // How should tabs be treated when they word-wrap on a print-out? + // if startcol != 0, this messes up (then again, word wrapping messes up anyway) + if (unicode[z] == QChar('\t')) + x -= x % width; + if (unicode[z].isSpace()) { lastWhiteSpace = z+1; @@ -816,11 +821,6 @@ } } - // How should tabs be treated when they word-wrap on a print-out? - // if startcol != 0, this messes up (then again, word wrapping messes up anyway) - if (unicode[z] == QChar('\t')) - x -= x % width; - if (x <= maxwidth) { if (lastWhiteSpace > -1) --- branches/KDE/3.5/kdelibs/kate/part/kateviewinternal.cpp #668823:668824 @@ -1653,7 +1653,22 @@ if (maxX && range.wrap) { QChar lastCharInLine = textLine(range.line)->getChar(range.endCol - 1); - maxX -= m_view->renderer()->config()->fontMetrics()->width(lastCharInLine); + + if (lastCharInLine == QChar('\t')) { + int lineSize = 0; + int lastTabSize = 0; + for(int i = range.startCol; i < range.endCol; i++) { + if (textLine(range.line)->getChar(i) == QChar('\t')) { + lastTabSize = m_view->tabWidth() - (lineSize % m_view->tabWidth()); + lineSize += lastTabSize; + } else { + lineSize++; + } + } + maxX -= lastTabSize * m_view->renderer()->spaceWidth(); + } else { + maxX -= m_view->renderer()->config()->fontMetrics()->width(lastCharInLine); + } } return maxX;
Quick note: The fix is not entirely correct. It does not make it worse, though, so I'll not revert for now. The problem is, that we always have to iterate through the list and handle the tab characters in order to have the correct maxX position. Is there a better way?
*** Bug 147104 has been marked as a duplicate of this bug. ***