After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 737959 - Differentiate between inclusive/exlusive and linewise/characterwise motions
Differentiate between inclusive/exlusive and linewise/characterwise motions
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-10-05 21:28 UTC by Florian Müllner
Modified: 2014-10-05 22:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vim: Fix selection-bound off-by-one error in forward-word (1.32 KB, patch)
2014-10-05 21:28 UTC, Florian Müllner
committed Details | Review
vim: Differentiate between inclusive/exclusive motions (5.54 KB, patch)
2014-10-05 21:28 UTC, Florian Müllner
committed Details | Review
vim: Support linewise motions (3.11 KB, patch)
2014-10-05 21:28 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2014-10-05 21:28:27 UTC
See patches. This makes stuff like 'dh' and 'dj' behave as expected ...
Comment 1 Florian Müllner 2014-10-05 21:28:30 UTC
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.
Comment 2 Florian Müllner 2014-10-05 21:28:35 UTC
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.
Comment 3 Florian Müllner 2014-10-05 21:28:44 UTC
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.
Comment 4 Christian Hergert 2014-10-05 21:55:46 UTC
Review of attachment 287783 [details] [review]:

Nice.
Comment 5 Christian Hergert 2014-10-05 21:57:00 UTC
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))
Comment 6 Christian Hergert 2014-10-05 21:57:28 UTC
Review of attachment 287781 [details] [review]:

lovely
Comment 7 Florian Müllner 2014-10-05 22:06:32 UTC
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