hints kitten: Fix matching of filenames enclosed in quotes or brackets not stripping the surrounding quotes properly. Fixes #4419

This commit is contained in:
Kovid Goyal 2022-01-04 10:58:31 +05:30
parent b6254e4a67
commit dae8ae33f0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -271,9 +271,13 @@ def brackets(text: str, s: int, e: int) -> Tuple[int, int]:
# Remove matching brackets # Remove matching brackets
if s < e <= len(text): if s < e <= len(text):
before = text[s] before = text[s]
if before in '({[<' and text[e-1] == closing_bracket_map[before]: if before in '({[<':
q = closing_bracket_map[before]
if text[e-1] == q:
s += 1 s += 1
e -= 1 e -= 1
elif text[e:e+1] == q:
s += 1
return s, e return s, e
@ -282,9 +286,12 @@ def quotes(text: str, s: int, e: int) -> Tuple[int, int]:
# Remove matching quotes # Remove matching quotes
if s < e <= len(text): if s < e <= len(text):
before = text[s] before = text[s]
if before in '\'"' and text[e-1] == before: if before in '\'"':
if text[e-1] == before:
s += 1 s += 1
e -= 1 e -= 1
elif text[e:e+1] == before:
s += 1
return s, e return s, e