Last (sub)-line in document displayed repetitively with word wrap

48 views
Skip to first unread message

Florian Balmer

unread,
Jun 5, 2013, 3:46:33 PM6/5/13
to scintilla...@googlegroups.com
I'd like to report an issue posted to me by a mindful user of Notepad2. I'm able to reproduce the problem with SciTE 3.3.3 on Windows (any version, Direct2D disabled):

1. Create a new document in SciTE
2. Enable word wrap (Options, Wrap)
3. Type some text, until the line is long enough to get wrapped
4. Insert two line breaks (hit Enter twice)
5. Type a shorter line of text (that won't wrap)
6. Move the caret to the end of the wrapped line typed in step 3
7. Hit Delete twice to join the two lines
8. Hit Ctrl+Z to undo the last action

The last (short) line is now visible two or more times (possibly depending on the number of sub-lines ("display lines") occupied by the longer, wrapped line typed in step 3). Once the text is modified again, the SciTE window is resized, or the word wrap option is changed, anything is fine, so this seems to be a display-only problem.

The problem does not appear if the shorter line typed in step 5 is not at the end of the document (i.e. followed by at least one line break). If the shorter line from step 5 is long enough to be wrapped, too, only the last sub-line will be repeated.

--Florian

Neil Hodgson

unread,
Jun 5, 2013, 8:34:19 PM6/5/13
to scintilla...@googlegroups.com
Florian Balmer:

The last (short) line is now visible two or more times (possibly depending on the number of sub-lines ("display lines") occupied by the longer, wrapped line typed in step 3). Once the text is modified again, the SciTE window is resized, or the word wrap option is changed, anything is fine, so this seems to be a display-only problem.

   The contraction state object wasn't correctly synchronized to the lines. Here is a potential patch but it may affect other code paths:

diff -r 6a2f299a13b1 src/Editor.cxx
--- a/src/Editor.cxx    Wed Jun 05 22:39:05 2013 +1000
+++ b/src/Editor.cxx    Thu Jun 06 10:28:37 2013 +1000
@@ -4742,6 +4742,8 @@
             // Update contraction state for inserted and removed lines
             // lineOfPos should be calculated in context of state before modification, shouldn't it
             int lineOfPos = pdoc->LineFromPosition(mh.position);
+            if (mh.position > pdoc->LineStart(lineOfPos))
+                lineOfPos++;    // Affecting subsequent lines
             if (mh.linesAdded > 0) {
                 cs.InsertLines(lineOfPos, mh.linesAdded);
             } else {

   Neil

wrapundo.patch

Florian Balmer

unread,
Jun 7, 2013, 1:48:07 PM6/7/13
to scintilla...@googlegroups.com, nyama...@me.com
Thank you very much for the quick update, it works fine!

I don't have the power to see if it affects any other code paths, so far I haven't seen any side effects, at least.

--Florian

Neil Hodgson

unread,
Jun 10, 2013, 10:40:20 PM6/10/13
to scintilla...@googlegroups.com
Florian Balmer:

> Thank you very much for the quick update, it works fine!
>
> I don't have the power to see if it affects any other code paths, so far I haven't seen any side effects, at least.

OK. committed to Hg.

For anyone that spots regressions in wrap mode, please report them.

Neil

Reply all
Reply to author
Forward
0 new messages