This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new b4a0990f2f LSP Client: Use full complete item to complete, not just 
the missing suffix
     new e2468f0ef3 Merge pull request #4728 from matthiasblaesing/lsp_insert
b4a0990f2f is described below

commit b4a0990f2f465554523b3532d97bf68a6d272b57
Author: Matthias Bläsing <mblaes...@doppel-helix.eu>
AuthorDate: Sat Oct 1 22:21:08 2022 +0200

    LSP Client: Use full complete item to complete, not just the missing suffix
    
    This is the test case (typescript):
    
    export class test {
        demo() {
            this.runstranget|
        }
    
        runStrangeThings(): void {
        }
    }
    
    
    The codecompletion at the | mark will offer "runStrangeThings", but
    completion will yield "this.runstrangethings". The reason is, that
    the CC is invoced case-insensitive, so the original string needs to be
    replaced with the full result.
---
 .../modules/lsp/client/bindings/CompletionProviderImpl.java   | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
 
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
index 0869a66500..d4eb07445f 100644
--- 
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
+++ 
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
@@ -213,9 +213,14 @@ public class CompletionProviderImpl implements 
CompletionProvider {
                                                 toAdd = i.getLabel();
                                             }
                                             int[] identSpan = 
Utilities.getIdentifierBlock((BaseDocument) doc, caretOffset);
-                                            String printSuffix = 
toAdd.substring(identSpan != null ? caretOffset - identSpan[0] : 0);
-                                            doc.insertString(caretOffset, 
printSuffix, null);
-                                            endPos = caretOffset + 
printSuffix.length();
+                                            if (identSpan != null) {
+                                                doc.remove(identSpan[0], 
identSpan[1] - identSpan[0]);
+                                                doc.insertString(identSpan[0], 
toAdd, null);
+                                                endPos = identSpan[0] + 
toAdd.length();
+                                            } else {
+                                                doc.insertString(caretOffset, 
toAdd, null);
+                                                endPos = caretOffset + 
toAdd.length();
+                                            }
                                         }
                                         doc.insertString(endPos, appendText, 
null);
                                     } catch (BadLocationException ex) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to