From 197b9549cff724ff1642bd0719b2264c372d8359 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Wed, 17 Apr 2019 17:24:56 -0400 Subject: [PATCH] PT #165432307: Properly set insertion format for document edits --- .../completion/DocumentEdits.java | 11 ++++++-- .../completion/ICompletionProposal.java | 3 -- .../completion/SimpleCompletionFactory.java | 4 +-- .../VscodeCompletionEngineAdapter.java | 28 +++++++++++-------- .../util/SimpleLanguageServer.java | 5 ++++ .../completion/DefaultCompletionFactory.java | 2 +- .../yaml/completion/YTypeAssistContext.java | 8 +++--- .../yaml/completion/YamlPathEdits.java | 4 +-- .../testharness/LanguageServerHarness.java | 4 +-- .../completion/DocumentEditsTest.java | 2 +- .../manifest/yaml/RouteContentAssistant.java | 4 +-- .../DataRepositoryCompletionProcessor.java | 5 ++-- .../java/data/FindByCompletionProposal.java | 9 +----- .../boot/java/jdt/imports/ImportRewrite.java | 6 ++-- .../scope/ScopeNameCompletionProposal.java | 4 +-- .../java/snippets/JavaSnippetBuilder.java | 4 +-- .../java/value/ValueCompletionProcessor.java | 15 +++++----- .../java/value/ValuePropertyKeyProposal.java | 16 +++-------- ...opertiesCompletionProposalsCalculator.java | 8 +++--- .../BeanRefCompletionProposalProvider.java | 7 ++--- ...ropertyNameCompletionProposalProvider.java | 2 +- .../TypeCompletionProposalProvider.java | 5 ++-- .../ApplicationYamlAssistContext.java | 2 +- 23 files changed, 76 insertions(+), 82 deletions(-) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java index 914d791be..181d5db2d 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Pivotal, Inc. + * Copyright (c) 2015, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -322,6 +322,7 @@ public class DocumentEdits implements ProposalApplier { private List edits = new ArrayList(); private IDocument doc; + final private boolean hasSnippets; /** * When this is true, the cursor is moved after each edit, to be positioned right after the @@ -332,8 +333,9 @@ public class DocumentEdits implements ProposalApplier { */ private boolean grabCursor = true; - public DocumentEdits(IDocument doc) { + public DocumentEdits(IDocument doc, boolean hasSnippets) { this.doc = doc; + this.hasSnippets = hasSnippets; } public void delete(int start, int end) { @@ -493,4 +495,9 @@ public class DocumentEdits implements ProposalApplier { public boolean hasRelativeIndents() { return true; } + + final public boolean hasSnippets() { + return hasSnippets; + } + } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java index 28ad4242f..3774189e3 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java @@ -14,7 +14,6 @@ package org.springframework.ide.vscode.commons.languageserver.completion; import java.util.Optional; import org.eclipse.lsp4j.CompletionItemKind; -import org.eclipse.lsp4j.InsertTextFormat; import org.springframework.ide.vscode.commons.util.Renderable; /** @@ -38,8 +37,6 @@ public interface ICompletionProposal { */ default ICompletionProposal deemphasize(double howmuch) { return this; } - default InsertTextFormat getInsertTextFormat() { return InsertTextFormat.Snippet; } - default boolean isDeprecated() { return false; } } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/SimpleCompletionFactory.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/SimpleCompletionFactory.java index e40b24dc8..1d96881e9 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/SimpleCompletionFactory.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/SimpleCompletionFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Pivotal, Inc. + * Copyright (c) 2017, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -77,7 +77,7 @@ public class SimpleCompletionFactory { } public static SimpleProposal simpleProposal(IDocument doc, int offset, String query, CompletionItemKind kind, String value, String detail, Renderable info) { - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.replace(offset-query.length(), offset, value); return new SimpleProposal(edits, kind, info, detail, value); } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java index 9ad0bfe57..7857c04ce 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java @@ -17,10 +17,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionList; +import org.eclipse.lsp4j.InsertTextFormat; import org.eclipse.lsp4j.MarkupContent; import org.eclipse.lsp4j.MarkupKind; import org.eclipse.lsp4j.Position; @@ -29,8 +31,6 @@ import org.eclipse.lsp4j.TextEdit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits.TextReplace; -import org.springframework.ide.vscode.commons.languageserver.util.LspClient; -import org.springframework.ide.vscode.commons.languageserver.util.LspClient.Client; import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService; import org.springframework.ide.vscode.commons.languageserver.util.SortKeys; @@ -217,16 +217,21 @@ public class VscodeCompletionEngineAdapter implements VscodeCompletionEngine { } private void resolveEdits(TextDocument doc, ICompletionProposal completion, CompletionItem item) { - Optional mainEdit = adaptEdits(doc, completion.getTextEdit()); + AtomicBoolean usedSnippets = new AtomicBoolean(); + Optional mainEdit = adaptEdits(doc, completion.getTextEdit(), usedSnippets); if (mainEdit.isPresent()) { item.setTextEdit(mainEdit.get()); - item.setInsertTextFormat(completion.getInsertTextFormat()); + if (server.hasCompletionSnippetSupport()) { + item.setInsertTextFormat(usedSnippets.get() ? InsertTextFormat.Snippet : InsertTextFormat.PlainText); + } else { + item.setInsertTextFormat(InsertTextFormat.PlainText); + } } else { item.setInsertText(""); } completion.getAdditionalEdit().ifPresent(edit -> { - adaptEdits(doc, edit).ifPresent(extraEdit -> { + adaptEdits(doc, edit, null).ifPresent(extraEdit -> { item.setAdditionalTextEdits(ImmutableList.of(extraEdit)); }); }); @@ -239,9 +244,12 @@ public class VscodeCompletionEngineAdapter implements VscodeCompletionEngine { return null; } - private Optional adaptEdits(TextDocument doc, DocumentEdits edits) { + private Optional adaptEdits(TextDocument doc, DocumentEdits edits, AtomicBoolean usedSnippets) { try { TextReplace replaceEdit = edits.asReplacement(doc); + if (usedSnippets != null) { + usedSnippets.set(edits.hasSnippets()); + } if (replaceEdit==null) { //The original edit does nothing. return Optional.empty(); @@ -252,25 +260,23 @@ public class VscodeCompletionEngineAdapter implements VscodeCompletionEngine { vscodeEdit.setRange(doc.toRange(replaceEdit.start, replaceEdit.end-replaceEdit.start)); String newText = replaceEdit.newText; IRegion selection = edits.getSelection(); - if (selection!=null) { + if (selection!=null && usedSnippets != null) { //Special handling for the case where cursor is *not* just at the end of the newText int cursor = selection.getOffset() + selection.getLength(); cursor = cursor - replaceEdit.start; - if (cursor0) { - edits =new DocumentEdits(doc); + edits =new DocumentEdits(doc, false); buffer.append('\n'); for (String imp : createdImprts) { buffer.append("import "); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/scope/ScopeNameCompletionProposal.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/scope/ScopeNameCompletionProposal.java index 7a34a31b7..da9d5d5d0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/scope/ScopeNameCompletionProposal.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/scope/ScopeNameCompletionProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Pivotal, Inc. + * Copyright (c) 2017, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -57,7 +57,7 @@ public class ScopeNameCompletionProposal implements ICompletionProposal { @Override public DocumentEdits getTextEdit() { - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.replace(startOffset + prefix.length(), endOffset, completion.getValue().substring(prefix.length())); return edits; } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/snippets/JavaSnippetBuilder.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/snippets/JavaSnippetBuilder.java index e19c941ca..044e8a445 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/snippets/JavaSnippetBuilder.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/snippets/JavaSnippetBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 Pivotal, Inc. + * Copyright (c) 2017, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,7 +40,7 @@ public class JavaSnippetBuilder{ IDocument doc = query.getDocument(); IndentUtil indentUtil = new IndentUtil(doc); - DocumentEdits edit = new DocumentEdits(doc); + DocumentEdits edit = new DocumentEdits(doc, true); // PT 162103145 - Avoid creating a snippet with double `@` if the query is invoked after a `@` AND the template // also starts with a `@` diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValueCompletionProcessor.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValueCompletionProcessor.java index b0c2c10b7..ce3e7153f 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValueCompletionProcessor.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValueCompletionProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 Pivotal, Inc. + * Copyright (c) 2017, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,7 +24,6 @@ import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.MemberValuePair; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.StringLiteral; -import org.eclipse.lsp4j.InsertTextFormat; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.springframework.ide.vscode.boot.java.handlers.CompletionProvider; import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider; @@ -65,13 +64,13 @@ public class ValueCompletionProcessor implements CompletionProvider { for (Match match : matches) { - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.replace(offset, offset, "\"${" + match.data.getId() + "}\""); // PT-160455522: create a proposal with `PlainText` format type, because for vscode (but not Eclipse), if you send it as a snippet // and it is "place holder" as such `"${debug}"`, vscode may treat it as a snippet place holder, and insert an empty string // if it cannot resolve it. If sending this as plain text, then insertion happens correctly - ValuePropertyKeyProposal proposal = new ValuePropertyKeyProposal(edits, match, InsertTextFormat.PlainText); + ValuePropertyKeyProposal proposal = new ValuePropertyKeyProposal(edits, match); completions.add(proposal); } @@ -122,10 +121,10 @@ public class ValueCompletionProcessor implements CompletionProvider { for (Match match : matches) { - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.replace(startOffset, endOffset, proposalPrefix + "${" + match.data.getId() + "}" + proposalPostfix); - ValuePropertyKeyProposal proposal = new ValuePropertyKeyProposal(edits, match, InsertTextFormat.PlainText); + ValuePropertyKeyProposal proposal = new ValuePropertyKeyProposal(edits, match); completions.add(proposal); } @@ -158,13 +157,13 @@ public class ValueCompletionProcessor implements CompletionProvider { for (Match match : matches) { - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.replace(startOffset, endOffset, preCompletion + match.data.getId() + postCompletion); // PT 160455522: create a proposal with `PlainText` format type, because for vscode (but not Eclipse), if you send it as a snippet // and the proposal value is "place holder" as such `"${debug}"`, vscode may treat it as a snippet place holder, and insert an empty string // if it cannot resolve it. If sending this as plain text, then insertion happens correctly - ValuePropertyKeyProposal proposal = new ValuePropertyKeyProposal(edits, match, InsertTextFormat.PlainText); + ValuePropertyKeyProposal proposal = new ValuePropertyKeyProposal(edits, match); completions.add(proposal); } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValuePropertyKeyProposal.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValuePropertyKeyProposal.java index b6ba18bb7..ebda10560 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValuePropertyKeyProposal.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/value/ValuePropertyKeyProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017, 2018 Pivotal, Inc. + * Copyright (c) 2017, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,6 @@ package org.springframework.ide.vscode.boot.java.value; import org.eclipse.lsp4j.CompletionItemKind; -import org.eclipse.lsp4j.InsertTextFormat; import org.springframework.ide.vscode.boot.common.InformationTemplates; import org.springframework.ide.vscode.boot.metadata.PropertyInfo; import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits; @@ -29,19 +28,17 @@ public class ValuePropertyKeyProposal extends ScoreableProposal { private String detail; private Renderable documentation; private double score; - private InsertTextFormat textFormat; - private ValuePropertyKeyProposal(DocumentEdits edits, String label, String detail, double score, Renderable documentation, InsertTextFormat textFormat) { + private ValuePropertyKeyProposal(DocumentEdits edits, String label, String detail, double score, Renderable documentation) { this.edits = edits; this.label = label; this.detail = detail; this.documentation = documentation; this.score = score; - this.textFormat = textFormat; } - public ValuePropertyKeyProposal(DocumentEdits edits, Match match, InsertTextFormat textFormat) { - this(edits, match.data.getId(), match.data.getType(), match.score, InformationTemplates.createCompletionDocumentation(match.data), textFormat); + public ValuePropertyKeyProposal(DocumentEdits edits, Match match) { + this(edits, match.data.getId(), match.data.getType(), match.score, InformationTemplates.createCompletionDocumentation(match.data)); } @Override @@ -73,10 +70,5 @@ public class ValuePropertyKeyProposal extends ScoreableProposal { public double getBaseScore() { return score; } - - @Override - public InsertTextFormat getInsertTextFormat() { - return this.textFormat; - } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java index 5d9365140..45ce88d9f 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java @@ -235,7 +235,7 @@ public class PropertiesCompletionProposalsCalculator { if (score!=0) { Type valueType = prop.getType(); String postFix = propertyCompletionPostfix(typeUtil, valueType); - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.delete(navOffset+1, offset); edits.insert(offset, prop.getName()+postFix); proposals.add( @@ -290,7 +290,7 @@ public class PropertiesCompletionProposalsCalculator { String valueCandidate = hint.getValue(); double score = FuzzyMatcher.matchScore(query, valueCandidate); if (score != 0) { - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.delete(startOfValue, offset); edits.insert(offset, valueCandidate); String valueTypeName = typeUtil.niceTypeName(getValueType(index, typeUtil, propertyName)); @@ -343,13 +343,13 @@ public class PropertiesCompletionProposalsCalculator { docEdits = LazyProposalApplier.from(() -> { try { Type type = TypeParser.parse(match.data.getType()); - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); edits.delete(offset-prefix.length(), offset); edits.insert(offset, match.data.getId() + propertyCompletionPostfix(typeUtil, type)); return edits; } catch (Throwable t) { log.error("{}", t); - return new DocumentEdits(doc); + return new DocumentEdits(doc, false); } }); synchronized (proposals) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java index 0c203fd70..cd9da1579 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/BeanRefCompletionProposalProvider.java @@ -32,8 +32,6 @@ import org.springframework.ide.vscode.commons.util.FuzzyMatcher; import org.springframework.ide.vscode.commons.util.Renderable; import org.springframework.ide.vscode.commons.util.text.TextDocument; -import reactor.util.function.Tuple2; -import reactor.util.function.TupleExtensionsKt; import reactor.util.function.Tuples; /** @@ -86,9 +84,8 @@ public class BeanRefCompletionProposalProvider implements XMLCompletionProvider private ICompletionProposal createProposal(String beanID, TextDocument doc, int offset, String prefix, Double score) { CompletionItemKind kind = CompletionItemKind.Reference; - DocumentEdits edits = new DocumentEdits(doc); - edits.delete(offset - prefix.length(), offset); - edits.insert(offset, beanID); + DocumentEdits edits = new DocumentEdits(doc, false); + edits.replace(offset - prefix.length(), offset, beanID); Renderable renderable = null; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/PropertyNameCompletionProposalProvider.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/PropertyNameCompletionProposalProvider.java index 129359a64..09461bac0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/PropertyNameCompletionProposalProvider.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/PropertyNameCompletionProposalProvider.java @@ -89,7 +89,7 @@ public class PropertyNameCompletionProposalProvider implements XMLCompletionProv String label = getPropertyName(method); CompletionItemKind kind = CompletionItemKind.Method; - DocumentEdits edits = new DocumentEdits(doc); + DocumentEdits edits = new DocumentEdits(doc, false); String replaceString = "\"" + label + "\""; int replaceStart = tokenStart; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/TypeCompletionProposalProvider.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/TypeCompletionProposalProvider.java index 7192ef816..632f5c0e1 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/TypeCompletionProposalProvider.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/completions/TypeCompletionProposalProvider.java @@ -99,9 +99,8 @@ public class TypeCompletionProposalProvider implements XMLCompletionProvider { kind = CompletionItemKind.Property; } - DocumentEdits edits = new DocumentEdits(doc); - edits.delete(offset - prefix.length(), offset); - edits.insert(offset, type.getFullyQualifiedName()); + DocumentEdits edits = new DocumentEdits(doc, false); + edits.replace(offset - prefix.length(), offset, type.getFullyQualifiedName()); Renderable renderable = null; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java index 9b26ff9d2..23e50d0c0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java @@ -267,7 +267,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon String value = hint.getValue(); double score = FuzzyMatcher.matchScore(query, value); if (score!=0 && !value.equals(query)) { - DocumentEdits edits = new DocumentEdits(doc.getDocument()); + DocumentEdits edits = new DocumentEdits(doc.getDocument(), false); int valueStart = offset-query.length(); edits.delete(valueStart, offset); if (doc.getChar(valueStart-1)==':') {