Fixed TextInput _move_cursor_word_left / right for wrapped words
Fixed two bugs:
- TextInput and CodeNavigationBehavior _move_cursor_word_left , _move_cursor_word_right methods move cursor only to the beginning / end of the current line for wrapped words, not to the beginning / end of the word itself.
- For the case below CodeNavigationBehavior._move_cursor_word_right (i.e. Ctrl + Right shortcut) doesn't do anything at all.

Note:
CodeNavigationBehavior._move_cursor_word_right moves cursor to the beginning of the next word.
So for the following example
('a...a' and 'b...b' are different words)
A) When cursor is at the end of the first line it should move to the beginning of the second line (i.e. beginning of the word 'b...b'),
B) When cursor is at the beginning of the second line it should move to the end of the text.
But since _move_cursor_word_left gets cursor index as an argument, it acts the same in both cases above (because cursor indices are the same). That's why currently in case B cursor also doesn't move at all.
The direct way to fix it is to change cursor index argument to cursor position. But not sure that it's worth it taking backward compatibility into account.
So in the fix for both cases _move_cursor_word_left acts as in the case B. But it's not a big deal, cause in case A cursor is already almost at the beginning of the word 'b...b'.
Maintainer merge checklist
- [ ] Title is descriptive/clear for inclusion in release notes.
- [ ] Applied a
Component: xxxlabel. - [ ] Applied the
api-deprecationorapi-breaklabel. - [ ] Applied the
release-highlightlabel to be highlighted in release notes. - [ ] Added to the milestone version it was merged into.
- [ ] Unittests are included in PR.
- [ ] Properly documented, including
versionadded,versionchangedas needed.
As I understand, the fail is caused by the line
import kivy.uix.textinput as textinput
in codenavigation.py.
Does anyone have any idea why?
For now I see only two alternatives: A) Set
self.FL_IS_LINEBREAK = FL_IS_LINEBREAK
self.FL_IS_WORDBREAK = FL_IS_WORDBREAK
inside TextInput.__init__ and use self.FL_IS_LINEBREAK, self.FL_IS_WORDBREAK in codenavigation.py, but it seems a bit odd.
B) Move _move_cursor_word_left and _move_cursor_word_right to CodeInput class, and therefore remove codenavigation.py (as it becomes empty). Actually currently I don't see any disadvantages.
Decided to put FL_IS_LINEBREAK, FL_IS_WORDBREAK into CodeInput attributes.