@@ -740,6 +740,16 @@ def _create_async_completer(self, buffer):
740740 """
741741 complete_thread_running = [False ] # By ref.
742742
743+ def completion_does_nothing (document , completion ):
744+ """
745+ Return `True` if applying this completion doesn't have any effect.
746+ (When it doesn't insert any new text.
747+ """
748+ text_before_cursor = document .text_before_cursor
749+ replaced_text = text_before_cursor [
750+ len (text_before_cursor ) + completion .start_position :]
751+ return replaced_text == completion .text
752+
743753 def async_completer (select_first = False , select_last = False ,
744754 insert_common_part = False , complete_event = None ):
745755 document = buffer .document
@@ -768,6 +778,12 @@ def callback():
768778 """
769779 complete_thread_running [0 ] = False
770780
781+ # When there is only one completion, which has nothing to add, ignore it.
782+ text_before_cursor = document .text_before_cursor
783+ if (len (completions ) == 1 and
784+ completion_does_nothing (document , completions [0 ])):
785+ del completions [:]
786+
771787 # Set completions if the text was not yet changed.
772788 if buffer .text == document .text and \
773789 buffer .cursor_position == document .cursor_position and \
0 commit comments