Cursor is moved to the end. To the line next to end of selection but at least to the last line of selection.
Actual behavior
Even if you selected 1000 lines pressing down will move cursor to the second line of selection.
NOTE: Pressing up works correctly and moves cursor up
How it was found and what problem it brought
I needed to select whole lines in custom sidebar on moving up and down. Something like the thing you can see in filemanager plugin. And the following example works while you run micro with disabled softwrap. But when you enable softwrap (and make sure that line you currently selected is softwrapped) pressing down will move cursor to the next "visual" line but it will be the same "actual" line. When you are on the second "visual" line of text the "SelectLine()" will select whole "actual" line. Pressing down will move it to the second "visual" line and now we are in a loop...
Minimal reproducible example, just copy it as plugin to your plugin dir to
function onCursorDown(buffer_pane)
buffer_pane:SelectLine()
end
function onCursorUp(buffer_pane)
buffer_pane:SelectLine()
end
Mouse inconsistency
Like mentioned in https://github.com/zyedidia/micro/issues/3055 if you select something with mouse the direction from what you selected text matters. If you selected text from up to bottom, everything works as with keyboard selection but. But if you select line from bottom to up the things will swap: pressing up will result in moving cursor to the one line up before last line and pressing down will work correctly and normally.
About filemanager and workaround
I tried to overcome the bug and found the workaround the same is in filemanager plugin. The pressing up is done via onCursorUp hook because pressing up works good but pressing down is handled in different way. It is done via preCursorDown that handles cursor down movement before it happens and manually moves cursor down and then return false from hook to let micro know that the action was handled and micro mustn't perform it....
Description of the problem or steps to reproduce
Expected behavior
Cursor is moved to the end. To the line next to end of selection but at least to the last line of selection.
Actual behavior
Even if you selected 1000 lines pressing down will move cursor to the second line of selection. NOTE: Pressing up works correctly and moves cursor up
How it was found and what problem it brought
I needed to select whole lines in custom sidebar on moving up and down. Something like the thing you can see in
filemanager
plugin. And the following example works while you run micro with disabled softwrap. But when you enable softwrap (and make sure that line you currently selected is softwrapped) pressing down will move cursor to the next "visual" line but it will be the same "actual" line. When you are on the second "visual" line of text the "SelectLine()" will select whole "actual" line. Pressing down will move it to the second "visual" line and now we are in a loop...Minimal reproducible example, just copy it as plugin to your plugin dir to
Mouse inconsistency
Like mentioned in https://github.com/zyedidia/micro/issues/3055 if you select something with mouse the direction from what you selected text matters. If you selected text from up to bottom, everything works as with keyboard selection but. But if you select line from bottom to up the things will swap: pressing up will result in moving cursor to the one line up before last line and pressing down will work correctly and normally.
About filemanager and workaround
I tried to overcome the bug and found the workaround the same is in
filemanager
plugin. The pressing up is done viaonCursorUp
hook because pressing up works good but pressing down is handled in different way. It is done viapreCursorDown
that handles cursor down movement before it happens and manually moves cursor down and then returnfalse
from hook to let micro know that the action was handled and micro mustn't perform it....https://github.com/micro-editor/updated-plugins/blob/216ec3adaf3adec78665614402ece56cf60ae713/filemanager-plugin/filemanager.lua#L1024-L1037
Possible root of the problem
UpN
function that is also used for down don't respectCurrentSelection
and just use itself like it is simple 1 char cursorhttps://github.com/zyedidia/micro/blob/2d82362a6695a7e898455ce016449167ac439ddd/internal/buffer/cursor.go#L232-L255
Specifications
Commit hash: https://github.com/zyedidia/micro/commit/68d88b571de6dca9fb8f03e2a3caafa2287c38d4 OS: Debian12 Terminal: foot