Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isearch - End highlight when no range found #1725

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion extensions/vi-mode/tests/ex.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@
(with-vi-buffer (#?"[p]en pineapple apple pen\napple juice\npineapple cake\n")
(cmd "Vj")
(ex-cmd "'<,'>s/apple/grape")
(ok (text= #?"pen pinegrape apple pen\ngrape juice\npineapple cake\n"))))
(ok (text= #?"pen pinegrape apple pen\ngrape juice\npineapple cake\n")))

;; Regexp Replacements
(with-vi-buffer (#?"line 1\nl[i]ne 2\nline 3\nline 4\n")
(cmd "Vj")
(ex-cmd "'<,'>s/^/foo - /")
(ok (text= #?"line 1\nfoo - line 2\nfoo - line 3\nline 4\n")))
(with-vi-buffer (#?"line 1\nl[i]ne 2\nline 3\nline 4\n")
(cmd "Vj")
(ex-cmd "'<,'>s/$/ - bar/")
(ok (text= #?"line 1\nline 2 - bar\nline 3 - bar\nline 4\n")))
)
(testing "'g' flag"
(with-vi-buffer (#?"pen pineapple <apple pen\nap[p]>le juice\npineapple cake\n")
(ex-cmd "'<,'>s/apple/grape/g")
Expand Down
13 changes: 7 additions & 6 deletions src/ext/isearch.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@
(return-from highlight-region nil))
(with-point ((p start-point))
(loop
(unless (funcall *isearch-search-forward-function* p search-string end-point)
(return))
(with-point ((before p))
(funcall *isearch-search-backward-function* before search-string)
(isearch-add-overlay buffer
(make-overlay before p 'isearch-highlight-attribute)))))
(unless (or (funcall *isearch-search-forward-function* p search-string end-point)
(point= start-point end-point)))
(return))
(with-point ((before p))
(funcall *isearch-search-backward-function* before search-string)
(isearch-add-overlay buffer
(make-overlay before p 'isearch-highlight-attribute))))
(isearch-sort-overlays buffer))))

(defun isearch-update-display ()
Expand Down
Loading