[
https://issues.apache.org/jira/browse/NETBEANS-980?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eirik Bakke updated NETBEANS-980:
-
Description:
Caret movements via Home/End and arrow Up/Down keys do not work properly when
text wrap (especially in "after words" mode) is enabled in the NetBeans editor.
Specific bugs:
1) Pressing Home (Fn+Left Arrow on MacBooks) will bring the text caret to the
beginning of the paragraph rather than to the beginning of the current wrap
line (physical line).
2) Pressing End (Fn+Right Arrow on MacBooks) will bring the text caret to the
beginning of the next wrap line instead of to the end of the current wrap line.
3) Pressing Up has no effect if the preceding wrap line ended before the
caret's current X position.
4) Pressing Down will move the caret down _two_ lines if the following wrap
line ended before the caret's current X position (and assuming the wrap line
two lines down is longer).
5) Left-clicking the mouse to the right of the end of a wrap line puts the
caret on the beginning of the next wrap line rather than at the end of the
current (clicked) wrap line.
The Home/End/Up/Down actions are all implemented in o.n.editor.BaseKit
(UpAction/DownAction/BeginLineAction/EndLineAction).
Bug number 1 above, for the Home action (BeginLineAction), is easy to fix
(don't allow Utilities.getRowFirstNonWhite to move cursor before lineStartPos)
and is unrelated to the others.
Bugs 2-5 above all relate to what caret position is mapped to the "infinite"
horizontal space that follows each wrap line. With NetBeans' current behavior,
this space corresponds to a caret position directly following the last
character of a wrap line. This caret position, however, is physically mapped
(and painted) on the beginning of the following wrap line, which confuses the
logic for the End, Up, and Down actions. I suspect that if bug 5 is fixed, then
bugs 2-4 might "fix themselves" as well.
For bug 5, I think the best solution when clicking the space beyond the end of
a wrap line would be to move the caret to right _before_ the last character on
the wrap line. This character is usually a space (in word wrap mode), though it
could also be a hyphen or such if a more advanced word wrapping algorithm is
used (proposed in the pull request for NETBEANS-977). This behavior would be
similar to that of a default JTextArea, or jEdit (neither which break words on
anything else than a space). Another solution would be to do like the TextEdit
app on MacOS, where the cursor is placed _after_ the last character on the wrap
line, but with a backwards bias such that the cursor is painted on the end of
the current wrap line instead of on the beginning of the next wrap line. The
latter is probably harder to implement, and is not really necessary.
To test the above bugs:
1) Go to Options/Preferences->Editor->Formatting, select "All Languages" and
set "Line Wrap" to "After words". Click OK.
2) Create a new plain text file and paste in the paragraph "SHORTWORD
LONGWORD SHORTWORD LUUUNGWORD".
3) Resize the editor window so that the paragraph gets split into four wrap
lines (one word on each wrap line--i.e. make the editor a little wider than the
long word).
4) For each bugs 1-4 listed above, position the caret right after "...ONG",
then press the relevant key to test.
5) To test bug 5 above, click the mouse to the right of the first, second, or
third wrap line.
Tested in NetBeans 9.0 rc1.
was:
If line wrap is enabled, and the text caret is located in a wrapped paragraph,
the up/down arrow keys cannot be used to move the caret up/down to another wrap
line if the target wrap line is shorter than the current caret position. Either
nothing happens, or the caret may skip the shorter wrap lines and step multiple
wrap lines up/down.
To reproduce:
1) Go to Options/Preferences->Editor->Formatting, select "All Languages" and
set "Line Wrap" to "After words". Click OK.
2) Create a new plain text file and paste in the paragraph "SHORTWORD
LONGWORD SHORTWORD LUUUNGWORD".
3) Resize the editor window so that the paragraph gets split into three wrap
lines (one word on each wrap line--i.e. make the editor a little wider than the
long word).
4) Position the cursor right after "...ONG"
5) Press the "Up" arrow. Nothing happens (expected would be to the caret to
move up to the end of the previous wrap line).
6) Press the "Down" arrow. This moves the caret _two_ wrap lines down instead
of to the end of the next wrap line.
Tested in NetBeans 9.0 rc1.
> Home/end/up/down does not work properly when word wrapping is enabled
> -
>
> Key: NETBEANS-980
> URL: https://issues.apache.org/jira/browse/NETBEANS-980
> Project: NetBeans
> Issue Type: Bug
>