GNOME Bugzilla – Bug 737959
Differentiate between inclusive/exlusive and linewise/characterwise motions
Last modified: 2014-10-05 22:06:57 UTC
See patches. This makes stuff like 'dh' and 'dj' behave as expected ...
Created attachment 287781 [details] [review] vim: Fix selection-bound off-by-one error in forward-word 'w' should move to the start (e.g. first character) of the next word. The iter we move around indeed corresponds to this position, so the movements without a selection turns out right - however when using the iter as selection-bound, the selections extents up to - but not including - the iter's position. Moving the iter one character further fixes this, though we temporarily break its use as modifier ('dw') due to another off-by-one error in the opposite direction.
Created attachment 287782 [details] [review] vim: Differentiate between inclusive/exclusive motions Motions are either inclusive or exclusive. While there is no difference when used standalone, when the motion is used as modifier to a command, the range of characters the command applies to differs - in case of an exclusive motion, the command does not apply to the left-most character described by the motions. An example probably illustrates it best - with a buffer of 'foo bar baz', and the cursor at the beginning of the 2nd word: - 'de' deletes 'bar' (as 'e' is an inclusive motion) - 'dl' deletes 'b' (as 'l' is exclusive) - 'dh' deletes the space before 'bar' (as 'h' is exclusive as well) The current behavior implements the one for inclusive motions, this patch flags exclusive motions as such and corrects their behavior.
Created attachment 287783 [details] [review] vim: Support linewise motions Motions can be either character- or linewise when used as modifiers to a command. The commands will operate on entire lines when the motion is linewise, e.g. 'dj' deletes two lines (rather than from the cursor position to to the same column on the following line). Add another flag to support this.
Review of attachment 287783 [details] [review]: Nice.
Review of attachment 287782 [details] [review]: Looks good. ::: src/editor/gb-editor-vim.c @@ +1213,3 @@ cmd->func (vim, count, '\0'); + + if (cmd->flags & GB_EDITOR_VIM_COMMAND_FLAG_MOTION_EXCLUSIVE) Maybe add () to avoid compiler warnings with stricter checks. if ((cmd->flags & GB_EDITOR_VIM_COMMAND_FLAG_MOTION_EXCLUSIVE))
Review of attachment 287781 [details] [review]: lovely
Attachment 287781 [details] pushed as 61d5432 - vim: Fix selection-bound off-by-one error in forward-word Attachment 287782 [details] pushed as 83e3175 - vim: Differentiate between inclusive/exclusive motions Attachment 287783 [details] pushed as 0aa48ed - vim: Support linewise motions