Skip to content

Commit

Permalink
multiline search #12
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Jul 13, 2024
1 parent 91528bc commit 76c40d6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pyvim/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def _document_find(
else:
text = text[1:]

flags = re.IGNORECASE if ignore_case else 0
flags = re.MULTILINE
if ignore_case:
flags |= re.IGNORECASE
try:
iterator = re.finditer(sub, text, flags)
except re.error:
Expand All @@ -67,7 +69,9 @@ def _document_find_all(self, sub: str, ignore_case: bool = False) -> list[int]:
Find all occurrences of the substring. Return a list of absolute
positions in the document.
"""
flags = re.IGNORECASE if ignore_case else 0
flags = re.MULTILINE
if ignore_case:
flags |= re.IGNORECASE
try:
return [a.start() for a in re.finditer(sub, self.text, flags)]
except re.error:
Expand All @@ -92,7 +96,9 @@ def _document_find_backwards(
else:
before_cursor = self.text_before_cursor[::-1]

flags = re.IGNORECASE if ignore_case else 0
flags = re.MULTILINE
if ignore_case:
flags |= re.IGNORECASE
# TODO: search backword with regular expression like _document_find() and _document_find_all()
iterator = re.finditer(re.escape(sub[::-1]), before_cursor, flags)

Expand Down

0 comments on commit 76c40d6

Please sign in to comment.