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 743668 - more vim compliant search behavior
more vim compliant search behavior
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: editor
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-28 21:30 UTC by Ray Strode [halfline]
Modified: 2015-01-29 10:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
editor: add search-direction property (17.69 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
editor: don't wrap manually when searching (5.89 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
editor: add rubberbanding argument to move_previous_match (13.98 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
editor: consistently match in current direction of search (5.34 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
vim: add search direction to begin-search signal (11.44 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
vim: implement '?' command (7.25 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
vim: expose search text as a property (17.67 KB, patch)
2015-01-28 21:30 UTC, Ray Strode [halfline]
committed Details | Review
vim: save search direction (20.56 KB, patch)
2015-01-28 21:31 UTC, Ray Strode [halfline]
committed Details | Review
vim: sync search text and direction from outside searches (6.35 KB, patch)
2015-01-28 21:31 UTC, Ray Strode [halfline]
committed Details | Review
vim: implement 'n' and 'N' commands (15.82 KB, patch)
2015-01-28 21:31 UTC, Ray Strode [halfline]
committed Details | Review

Description Ray Strode [halfline] 2015-01-28 21:30:32 UTC
So I've been using gnome-builder fairly regularly now instead of vim and
an issue I've bumped into is the lack of certain search features like '?'
and 'n'. In particular I normally use 'n' after doing '*', instead of
pressing '*' multiple times.

I've attempted to add those features with the below patchset.
The features seem to work okay with light testing, but I haven't used them
"in production" yet, so they might still have niggling issues.
Comment 1 Ray Strode [halfline] 2015-01-28 21:30:36 UTC
Created attachment 295694 [details] [review]
editor: add search-direction property

This commit adds a search-direction property that tracks the
direction the document is being searched. This change is a
necessary prerequisite for follow-up fixes.
Comment 2 Ray Strode [halfline] 2015-01-28 21:30:40 UTC
Created attachment 295695 [details] [review]
editor: don't wrap manually when searching

GtkSourceSearchSettings natively supports wrapping when
searching if the wrap-around property is set to TRUE.

gb_editor_frame_move_next_match wraps around manually.

This commit deletes the manual code and just sets wrap-around
to TRUE.
Comment 3 Ray Strode [halfline] 2015-01-28 21:30:43 UTC
Created attachment 295696 [details] [review]
editor: add rubberbanding argument to move_previous_match

gb_editor_frame_move_next_match() supports "rubberbanding" (the
ability to stay stationed on a match as the user types more and
more matching characters, with the ability to abort the operation
without moving via the escape key), but
gb_editor_frame_move_previous_match() doesn't. We're
ultimately going to need that functionality for matching
backwards, too, to get optimal search behavior.

This commit implements both functions in terms of a common
gb_editor_frame_match() function that takes an additional
"direction" argument, and adds a "rubberbanding" argument to
the gb_editor_frame_move_previous_match function.
Comment 4 Ray Strode [halfline] 2015-01-28 21:30:47 UTC
Created attachment 295697 [details] [review]
editor: consistently match in current direction of search

There are parts of the code that neglect to consult the
current search direction when deciding which way to match,
and instead just unconditionally match forward.

This commit fixes those places in the code.
Comment 5 Ray Strode [halfline] 2015-01-28 21:30:51 UTC
Created attachment 295698 [details] [review]
vim: add search direction to begin-search signal

This commit adds the search direction to the begin-search signal.
It will be necessary for implementing the '?' command.
Comment 6 Ray Strode [halfline] 2015-01-28 21:30:54 UTC
Created attachment 295699 [details] [review]
vim: implement '?' command

The '?' command is just like the '/' but in reverse.
This commit adds support for it.
Comment 7 Ray Strode [halfline] 2015-01-28 21:30:57 UTC
Created attachment 295700 [details] [review]
vim: expose search text as a property

This commit exposes the search text generated from the
'*' command as a property on the vim object. This
change is necessary as a prerequisite for adding
support for the 'n' command, which will happen in
a subsequent commit.
Comment 8 Ray Strode [halfline] 2015-01-28 21:31:00 UTC
Created attachment 295701 [details] [review]
vim: save search direction

We're going to need the search direction to implement the
'n' command, since the 'n' command replays the last search
in the direction of the last search.

This commit saves the search direction from the '*' and '#'
commands in a new search-direction property on the vim object.
Comment 9 Ray Strode [halfline] 2015-01-28 21:31:03 UTC
Created attachment 295702 [details] [review]
vim: sync search text and direction from outside searches

This commit saves the text and direction for searches initiated from
the view/frame on the vim object.  This change will be necessary for
implementing the 'n' command, since the 'n' command needs to replay
the last search (be it from '*', '/' or the menu).
Comment 10 Ray Strode [halfline] 2015-01-28 21:31:07 UTC
Created attachment 295703 [details] [review]
vim: implement 'n' and 'N' commands

This commit implements the 'n' (and 'N') command to replay the last search and
jump to the next (or previous respectively) result.
Comment 11 Christian Hergert 2015-01-29 10:07:44 UTC
These all seem to work pretty well for me now, thanks for implementing them!
If we find any bugs in this we can deal with them on a case by case basis in new bugs.

Attachment 295694 [details] pushed as b93676e - editor: add search-direction property
Attachment 295695 [details] pushed as 0c586b8 - editor: don't wrap manually when searching
Attachment 295696 [details] pushed as b2014c9 - editor: add rubberbanding argument to move_previous_match
Attachment 295697 [details] pushed as 9eeec89 - editor: consistently match in current direction of search
Attachment 295698 [details] pushed as 871b3ae - vim: add search direction to begin-search signal
Attachment 295699 [details] pushed as 18dc0d9 - vim: implement '?' command
Attachment 295700 [details] pushed as cff18d5 - vim: expose search text as a property
Attachment 295701 [details] pushed as ac5a386 - vim: save search direction
Attachment 295702 [details] pushed as ce4a14b - vim: sync search text and direction from outside searches
Attachment 295703 [details] pushed as 0e109e1 - vim: implement 'n' and 'N' commands