Skip to content

Commit

Permalink
search-buffer: Don't use regexps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ambrevar committed Jun 22, 2021
1 parent c4b9332 commit 78fedea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/search-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@

(defun get-substring-indices (query string)
"Get the indices of all matching substrings."
(let ((rgx (ps:new (|RegExp| query (if (ps:lisp case-sensitive-p) "" "i"))))
(let ((query (if (ps:lisp case-sensitive-p)
query
(ps:chain query (to-lower-case))))
(string (if (ps:lisp case-sensitive-p)
string
(ps:chain string (to-lower-case))))
(index (- (length query))))
(loop with subindex = 0
until (= subindex -1)
do (setf subindex (ps:chain string (search rgx)))
do (setf subindex (ps:chain string (index-of query)))
(setf string (ps:chain string (substring (+ subindex (length query)))))
(setf index (+ index subindex (length query)))
when (not (= subindex -1))
Expand Down

0 comments on commit 78fedea

Please sign in to comment.