Skip to content

Commit 5f31691

Browse files
committed
Editor: Minor improvements to TextEditBaseWidget.insert_completion
1 parent 1ff41d5 commit 5f31691

File tree

1 file changed

+4
-5
lines changed
  • spyder/plugins/editor/widgets

1 file changed

+4
-5
lines changed

spyder/plugins/editor/widgets/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,12 +938,12 @@ def insert_completion(self, completion, completion_position):
938938
end = self.get_position_line_number(end_line, end_col)
939939
cursor.setPosition(start)
940940
cursor.setPosition(end, QTextCursor.KeepAnchor)
941-
text = to_text_string(completion['textEdit']['newText'])
941+
text = str(completion['textEdit']['newText'])
942942
else:
943943
text = completion
944944
if isinstance(completion, dict):
945945
text = completion['insertText']
946-
text = to_text_string(text)
946+
text = str(text)
947947

948948
# Get word to the left of the cursor.
949949
result = self.get_current_word_and_position(
@@ -953,13 +953,12 @@ def insert_completion(self, completion, completion_position):
953953
end_position = start_position + len(current_text)
954954

955955
# Check if the completion position is in the expected range
956-
if not start_position <= completion_position <= end_position:
956+
if not (start_position <= completion_position <= end_position):
957957
return
958958
cursor.setPosition(start_position)
959959

960960
# Remove the word under the cursor
961-
cursor.setPosition(end_position,
962-
QTextCursor.KeepAnchor)
961+
cursor.setPosition(end_position, QTextCursor.KeepAnchor)
963962
else:
964963
# Check if we are in the correct position
965964
if cursor.position() != completion_position:

0 commit comments

Comments
 (0)