Improve return values of some actions + some improvements by dmaluka · Pull Request #3352 · micro-editor/micro (original) (raw)
Return false if there is nothing to undo/redo.
This also fixes false "Undid action" and "Redid actions" infobar messages in the case when no action was actually undone or redone.
ClearInfo and ClearStatus actions do exactly the same thing. Let's keep them both, for compatibility reasons (who knows how many users are using either of the two), but at least document that there is no difference between the two.
When there is no selection (i.e. selection is empty), SkipMultiCursor searches for the empty text, "finds" it as the beginning of the buffer, and as a result, jumps to the beginning of the buffer, which confuses the user. Fix it.
If the original selection was not done by the user manually but as a result of the initial SpawnMultiCursor, deselect this original selection if we execute RemoveMultiCursor and there is no multicursor to remove (i.e. the original spawned cursor is the only one). This improves user experience by making RemoveMultiCursor behavior nicely symmetrical to SpawnMultiCursor.
Use Deselect() in order to place the cursor at the beginning of the selection, not at the end of it, and to refresh its LastVisualX.
SpawnMultiCursor and RemoveMultiCursor actions change the set of cursors, so we cannot assume that it stays the same. So refresh the
cursorslist after executing every action in the chain.If execAction() did not execute an action since it is not a multicursor, it should return true, not false, to not prevent executing next actions in the chain.
Instead of calling execAction() and then letting it check whether it should actually execute this action, do this check before calling execAction(), to make the code clear and straightforward.
Precisely: for multicursor actions, call execAction() in a loop for every cursor, but for non-multicursor actions, call execAction() just once, without a loop. This, in particular, allows to get rid of the hacky "c == nil" check, since we no longer iterate a slice that may change in the meantime (since SpawnMultiCursor and RemoveMultiCursor are non-multicursor actions and thus are no longer executed while iterating the slice).
Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request
This adds missing deselect calls that were present previously for RemoveAllMultiCursors before PR micro-editor#3352
dmaluka pushed a commit that referenced this pull request
This adds missing deselect calls that were present previously for RemoveAllMultiCursors before PR #3352
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})