Skip to content

Commit

Permalink
Merge pull request #1725 from Encryptoid/isearch-fix-highlight-with-r…
Browse files Browse the repository at this point in the history
…egex

isearch - End highlight when no range found
  • Loading branch information
cxxxr authored Dec 31, 2024
2 parents 52f8c5c + 1465ce7 commit b15c5bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
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

0 comments on commit b15c5bb

Please sign in to comment.