Files
gerrit/gerrit-gwtui/src/main/java/com
Michael Zhou 7fa704cdda DiffScreen: Improve search experience with Ctrl-F, Ctrl-G, etc.
Many users complain that the search functionality on the diff screen is
hard to use. This change mitigates the problem with a couple of
improvements:

1. Ctrl-F, Ctrl-G and Shift-Ctrl-G now bind to the search dialog box
provided by CodeMirror's search addon instead of the one provided by the
Vim keymap. Many users find CodeMirror's Vim search hard to use because
it isn't a faithful emulation of the Vim regexp. Instead, since it only
supports JavaScript regexp, queries like "++" and "(" would have to be
escaped as "\+\+" and "\(", which is quite painful. On the contrary,
the search addon happily accepts plain text as input. The user can also
use the "/query/" format to do a JavaScript regexp search. Note that the
user would need to escape queries for text that start and end with "/".
For example, "//" needs to be escaped as "////", but I expect that case
to be rare.

2. Enter and Shift-Enter navigate among the search results from the
CodeMirror search, just like they do in a normal browser search.
Note that "Enter" normally expands a comment / draft box on the active
line, but it is used for jumping to the next search result if highlight
is present from a CodeMirror search.

3. "Esc" now clears the search results from both the CodeMirror search
and the Vim search. This is particularly useful since we use "n" and "p"
for the navigation among both search results and diff chunks. Before,
the user had to use a hard-to-discover combination of "/" + "Esc" to
clear the search results.

The following behaviors are unchanged:

1. Since the changes are orthogonal to the Vim search, The existing
search functionality still works. The Vim search can still be activated
with "/", "*" or "#" ("?" has always been reserved for the help popup so
it's unavailable). "n" and "p" still navigate among the search results
when a Vim search is active.

2. If the user sets "Render" to "Slow" in the diff preferences and the
file is less than 4000 lines (huge), then Ctrl-F, Ctrl-G and
Shift-Ctrl-G fall back to the browser search.

Bug: Issue 3387, Issue 3388
Change-Id: Ib4b0fb248bdfb0817507cfafb44ab5b0c1b60ba4
2016-05-06 18:28:49 +00:00
..