himselfv / wakan

Japanese and Chinese learning tool with dictionary
36 stars 7 forks source link

Problems with handling empty lines at the end of the document #166

Closed himselfv closed 11 years ago

himselfv commented 11 years ago

Original report by me.

Originally reported on Google Code with ID 166

As a part of recent reworking of cursor code (Issue 164), cursor handling is broken
with empty lines at the end of the document.

Adding a line with Enter sometimes results in assertion failure by accessing invalid
graphical line from the list.

Adding a line with Enter sometimes results in line being added but the cursor remaining
at the end of the previous line.

It is impossible to put the cursor at the 0-th position on the new, empty line with
the mouse click. It is placed at the end of the last non-empty line instead.

It is still possible to put the cursor there with keyboard.

Reported by himselfv on 2013-05-01 16:42:28

himselfv commented 11 years ago
Assertion happens because we use GetCur/SetCur after adding a logical line but before
updating graphical ones.
Either we have to update graphical lines before that, or, better yet, use rcur (which
should work after changing logical lines).

Reported by himselfv on 2013-05-01 16:47:19

himselfv commented 11 years ago
Assertion fixed @r520. Rest remains.

Reported by himselfv on 2013-05-01 16:49:27

himselfv commented 11 years ago
Clarification:
> Adding a line with Enter sometimes results in line being added but the cursor remaining
at the end of the previous line.

This happens when you go to the end of the line with VK_END (=> CursorEnd is set) and
press Enter.
Does not happen when you go to the middle of the line and split it with Enter.
Still happens if you do backspace after that and then split it with Enter again.

Reported by himselfv on 2013-05-08 08:27:02

himselfv commented 11 years ago
Update:
The root of that problem was indeed that when setting rcur (underlying cursor position)
CursorEnd was not being cleared.
I cannot clear it with any SetRCur as it's also used by SetCur (visual cursor) which
expects CursorEnd to be preserved. (I can change that, but I'll also need to make sure
all other uses are fine with CursorEnd being cleared. I should probably do this.)

Anyway, there's more. If you have a bunch of empty logical lines together, there are
various problems with setting the cursor to the middle of it related to CursorEnd/no
CursorEnd. Will try to figure it out now.

Reported by himselfv on 2013-05-08 08:51:25

himselfv commented 11 years ago
Some fixes. Clearing CursorEnd when setting RCur, also not setting CursorEnd if we're
at the end of both graphical and logical line (happened through SetCur route, was the
case for some empty line problems)

Reported by himselfv on 2013-05-08 09:10:26

himselfv commented 11 years ago
Seems to be fixed @r524, will reopen if bugs return.

Reported by himselfv on 2013-05-13 08:41:58