File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
packages/jupyterlab-lsp/src/features/completion Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -401,7 +401,7 @@ export class LSPConnector
401
401
402
402
this . console . debug ( 'All promises set up and ready.' ) ;
403
403
return promise . then ( reply => {
404
- reply = this . suppress_if_needed ( reply , token ) ;
404
+ reply = this . suppress_if_needed ( reply , token , cursor ) ;
405
405
this . items = reply . items ;
406
406
this . trigger_kind = CompletionTriggerKind . Invoked ;
407
407
return reply ;
@@ -610,8 +610,24 @@ export class LSPConnector
610
610
611
611
private suppress_if_needed (
612
612
reply : CompletionHandler . ICompletionItemsReply ,
613
- token : CodeEditor . IToken
613
+ token : CodeEditor . IToken ,
614
+ cursor_at_request : CodeEditor . IPosition
614
615
) {
616
+ const cursor_now = this . _editor . getCursorPosition ( ) ;
617
+
618
+ // if the cursor advanced in the same line, the previously retrieved completions may still be useful
619
+ // if the line changed or cursor moved backwards then no reason to keep the suggestions
620
+ if (
621
+ cursor_at_request . line != cursor_now . line ||
622
+ cursor_now . column < cursor_at_request . column
623
+ ) {
624
+ return {
625
+ start : reply . start ,
626
+ end : reply . end ,
627
+ items : [ ]
628
+ } ;
629
+ }
630
+
615
631
if ( this . trigger_kind == AdditionalCompletionTriggerKinds . AutoInvoked ) {
616
632
if (
617
633
// do not auto-invoke if no match found
You can’t perform that action at this time.
0 commit comments