Trying to make jumpies work in lsp4e
This works 'in theory'. Alas, lsp4e doesn't seem to execute commands from a completion items. So cursor doesn't move. Also filtering in lsp4e is still bonkers too.
This commit is contained in:
@@ -35,6 +35,7 @@ import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.lsp4j.services.LanguageClientAware;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LoggingFormat;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LspClient;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
@@ -60,6 +61,7 @@ public abstract class LaunguageServerApp {
|
||||
private static final int SERVER_STANDALONE_PORT = 5007;
|
||||
|
||||
public static void start(String name, Provider<SimpleLanguageServer> languageServerFactory) throws IOException, InterruptedException {
|
||||
Log.info("ClientType = "+LspClient.currentClient());
|
||||
System.setProperty(STS4_LANGUAGESERVER_NAME, name); //makes it easy to recognize language server processes.
|
||||
LaunguageServerApp app = new LaunguageServerApp() {
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits.Direction;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits.OffsetTransformer;
|
||||
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.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
@@ -135,7 +137,7 @@ public class LspCompletionInterpreter implements IDocumentState {
|
||||
if (afterEdit!=null) additionalEdits.add(afterEdit);
|
||||
item.setAdditionalTextEdits(additionalEdits.build());
|
||||
|
||||
if (mainEdit!=null && mainEdit.getNewText().equals("")) {
|
||||
if (LspClient.currentClient()==Client.VSCODE && mainEdit!=null && mainEdit.getNewText().equals("")) {
|
||||
//Vscode handles this poorly and adds 'junk' instead.
|
||||
mainEdit.setNewText(" "); // Adding a space. It is still junk but it is at least not immediately visible.
|
||||
}
|
||||
|
||||
@@ -155,6 +155,16 @@ public class VscodeCompletionEngineAdapter implements VscodeCompletionEngine {
|
||||
}
|
||||
}
|
||||
list.setItems(items);
|
||||
System.err.println(">>> completions [isInconplete = "+list.isIncomplete()+"]");
|
||||
for (CompletionItem item : items) {
|
||||
System.err.println(
|
||||
"lbl = '"+item.getLabel()+"' " +
|
||||
"sort = '"+item.getSortText()+"' " +
|
||||
"filt = '"+item.getFilterText()+"' " +
|
||||
"newText = '"+item.getTextEdit().getNewText()+"'"
|
||||
);
|
||||
}
|
||||
System.err.println("<<< completions");
|
||||
return list;
|
||||
})
|
||||
.subscribeOn(Schedulers.elastic()); //!!! without this the mono will just be computed on the same thread that calls it.
|
||||
|
||||
@@ -1450,59 +1450,64 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
|
||||
}
|
||||
|
||||
@Test public void testJumpyInsertion() throws Exception {
|
||||
String[] names = {"foo", "nested", "bar"};
|
||||
int levels = 4;
|
||||
generateNestedProperties(levels, names, "");
|
||||
//We care more about eclipse for this test case because it fails for vscode
|
||||
// because we have to add some extra in vscode as a workaround for this bug:
|
||||
// https://github.com/Microsoft/vscode-languageserver-node/issues/361
|
||||
withSystemProperty("sts.lsp.client", "eclipse", () -> {
|
||||
String[] names = {"foo", "nested", "bar"};
|
||||
int levels = 4;
|
||||
generateNestedProperties(levels, names, "");
|
||||
|
||||
assertCompletion(
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
"other:\n" +
|
||||
"foo.nested.bar.b<*>"
|
||||
,
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
" bar: <*>\n" +
|
||||
"other:"
|
||||
);
|
||||
assertCompletion(
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
"other:\n" +
|
||||
"foo.nested.bar.b<*>"
|
||||
,
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
" bar: <*>\n" +
|
||||
"other:"
|
||||
);
|
||||
|
||||
assertCompletion(
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
"other:\n" +
|
||||
"foo.nested.nested.b<*>"
|
||||
,
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar: <*>\n"+
|
||||
"other:"
|
||||
);
|
||||
assertCompletion(
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
"other:\n" +
|
||||
"foo.nested.nested.b<*>"
|
||||
,
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar: <*>\n"+
|
||||
"other:"
|
||||
);
|
||||
|
||||
assertCompletion(
|
||||
"foo.nested.nested.b<*>\n" +
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
"other:"
|
||||
,
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar: <*>\n"+
|
||||
"other:"
|
||||
);
|
||||
assertCompletion(
|
||||
"foo.nested.nested.b<*>\n" +
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
"other:"
|
||||
,
|
||||
"foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar:\n" +
|
||||
" foo:\n" +
|
||||
" nested:\n" +
|
||||
" bar: <*>\n"+
|
||||
"other:"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@Test public void testBooleanValueCompletion() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user