Skip to content

Commit 113da63

Browse files
committed
Added logic for choosing quote type
1 parent f5e009e commit 113da63

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

cmd2.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,15 +1779,21 @@ def _handle_completion_token_quote(self, raw_completion_token):
17791779
# If common_prefix contains a space, then we must add an opening quote to it
17801780
if ' ' in common_prefix:
17811781

1782-
new_completion_token = '"' + common_prefix
1782+
# Figure out what kind of quote to add
1783+
if '"' in common_prefix:
1784+
quote = "'"
1785+
else:
1786+
quote = '"'
1787+
1788+
new_completion_token = quote + common_prefix
17831789

17841790
# Handle a single result
17851791
if len(self.completion_matches) == 1:
17861792
str_to_append = ''
17871793

17881794
# Add a closing quote if allowed
17891795
if self.allow_closing_quote:
1790-
str_to_append += '"'
1796+
str_to_append += quote
17911797

17921798
orig_line = readline.get_line_buffer()
17931799
endidx = readline.get_endidx()

0 commit comments

Comments
 (0)