allow aborting search in 'tog log' with backspace key
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/TODO b/TODO
index df3304b..ae70add 100644
--- a/TODO
+++ b/TODO
@@ -21,4 +21,3 @@ tog:
- allow moving to prev/next blamed line in diff view if opened from blame view,
similar to how the diff view can switch commits if opened from log view
- tog should have a command to list and log/browse references
-- it should be possible to abort a running search in the log view
diff --git a/tog/tog.1 b/tog/tog.1
index 98b6346..0e9a3f0 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -103,7 +103,10 @@ Open a
.Cm tree
view showing the tree for the currently selected commit.
.It Cm Backspace
-Show log entries for the parent directory of the currently selected path.
+Show log entries for the parent directory of the currently selected path,
+unless an active search is in progress in which case
+.Cm Backspace
+aborts the search.
.It Cm /
Prompt for a search pattern and start searching for matching commits.
The search pattern is an extended regular expression which is matched
@@ -113,8 +116,14 @@ Regular expression syntax is documented in
.Xr re_format 7 .
.It Cm n
Find the next commit which matches the current search pattern.
+Searching continues until either a match is found or the
+.Cm Backspace
+key is pressed.
.It Cm N
Find the previous commit which matches the current search pattern.
+Searching continues until either a match is found or the
+.Cm Backspace
+key is pressed.
.It Cm Ctrl+l
Reload the log view with new commits found in the repository.
.El
diff --git a/tog/tog.c b/tog/tog.c
index 419435b..4516ca1 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1755,6 +1755,10 @@ search_next_log_view(struct tog_view *view)
}
if (s->search_entry) {
+ if (wgetch(view->window) == KEY_BACKSPACE) {
+ view->search_next_done = 1;
+ return NULL;
+ }
if (view->searching == TOG_SEARCH_FORWARD)
entry = TAILQ_NEXT(s->search_entry, entry);
else