@@ -963,22 +963,45 @@ def insert_completion(self, completion, completion_position):
963
963
if current_text == '.' :
964
964
is_auto_completion_character = True
965
965
else :
966
- if current_text in self .auto_completion_characters :
966
+ if (
967
+ kind != CompletionItemKind .FILE and
968
+ current_text in self .auto_completion_characters
969
+ ):
967
970
is_auto_completion_character = True
968
971
969
972
# Adjustments for file completions
970
973
if kind == CompletionItemKind .FILE :
971
- # This is necessary to inseert file completions when
972
- # requesting them next to a colon
973
974
if current_text in ['"' , "'" ]:
975
+ # This is necessary to insert file completions when
976
+ # requesting them next to a colon
974
977
current_text = ''
975
978
start_position += 1
976
-
977
- # And this insert completions for files or directories that
978
- # start with a dot
979
- if current_text in ['".' , "'." ]:
979
+ elif current_text in ['".' , "'." ]:
980
+ # This inserts completions for files or directories
981
+ # that start with a dot
980
982
current_text = '.'
981
983
start_position += 1
984
+ elif current_text == '.' :
985
+ # This is needed if users are asking for file
986
+ # completions to the right of a dot
987
+ cursor_1 = self .textCursor ()
988
+ found_start = False
989
+
990
+ # Select text backwards until we find where the file
991
+ # name starts
992
+ while not found_start :
993
+ cursor_1 .movePosition (
994
+ QTextCursor .PreviousCharacter ,
995
+ QTextCursor .KeepAnchor ,
996
+ )
997
+
998
+ selection = str (cursor_1 .selectedText ())
999
+ if text .startswith (selection ):
1000
+ found_start = True
1001
+
1002
+ current_text = str (cursor_1 .selectedText ())
1003
+ start_position = cursor_1 .selectionStart ()
1004
+ end_position = cursor_1 .selectionEnd ()
982
1005
983
1006
if not is_auto_completion_character :
984
1007
# Check if the completion position is in the expected range
0 commit comments