Quote a completed value if it contains "

This commit is contained in:
Florian Bruhin 2017-09-15 20:28:04 +02:00
parent a7d5a98cc4
commit 4f6e085be8
2 changed files with 5 additions and 1 deletions

View File

@ -111,7 +111,7 @@ class Completer(QObject):
"""
if not s:
return "''"
elif any(c in s for c in ' \'\t\n\\'):
elif any(c in s for c in ' "\'\t\n\\'):
# use single quotes, and put single quotes into double quotes
# the string $'b is then quoted as '$'"'"'b'
return "'" + s.replace("'", "'\"'\"'") + "'"

View File

@ -240,6 +240,10 @@ def test_update_completion(txt, kind, pattern, pos_args, status_command_stub,
":set fonts hints '12px Hack'|"),
(":set fonts hints 'Comic| Sans'", '12px Hack',
":set fonts hints '12px Hack'|"),
# Make sure " is quoted properly
(':set url.start_pages \'["https://www.|example.com"]\'',
'["https://www.example.org"]',
':set url.start_pages \'["https://www.example.org"]\'|'),
# open has maxsplit=0, so treat the last two tokens as one and don't quote
(':open foo bar|', 'baz', ':open baz|'),
(':open foo| bar', 'baz', ':open baz|'),