Skip to content

Commit

Permalink
fix: issue with completions around multi choice snippets (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jul 10, 2023
1 parent fd0bc44 commit 7a07f85
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/forty-days-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@marko/language-server": patch
"marko-vscode": patch
---

VSCode has a regression which causes all intelisense to break after a completion with a multi choice snippet is provided. The language server currently uses that to provide completions for attributes defined with an `enum` value. To resolve this issue, enum completions are simplified to not provide the choice based completion until this is resolved in vscode or another workaround is found.
4 changes: 1 addition & 3 deletions packages/language-server/src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const service: Plugin = {
);
},
async doComplete(doc, params, cancel) {
let isIncomplete = false;
// TODO: this should handle CompletionList.itemDefaults.
// If there is a single responding plugin, pass through, otherwise need to apply the defaults to the completion items for the plugin.

Expand All @@ -70,7 +69,6 @@ const service: Plugin = {
curItems = cur;
} else {
curItems = cur.items;
isIncomplete ||= cur.isIncomplete;
}

for (const item of curItems) {
Expand All @@ -91,7 +89,7 @@ const service: Plugin = {
if (cancel.isCancellationRequested) return;

if (itemsByLabel.size) {
return { items: [...itemsByLabel.values()], isIncomplete };
return { items: [...itemsByLabel.values()], isIncomplete: true };
}
},
async doCompletionResolve(item, cancel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export function AttrName({
let snippet = attr.name;

if (attr.enum) {
snippet += `="\${1|${attr.enum.join()}|}"$0`;
// TODO: We should use the following, but vscode has a regression with multi choice snippets form the language server.
// snippet += `="\${1|${attr.enum.join()}|}"$0`;
snippet += `="$1"$0`;
} else {
switch (type) {
case "string":
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/src/__tests__/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("completion", () => {
await snap.inline(
() => suggest("<div aria-liv█>"),
`
<div aria-live="off">
<div aria-live="">
`
);
});
Expand Down
5 changes: 4 additions & 1 deletion packages/vscode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export async function activate(ctx: ExtensionContext) {
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for marko text documents
documentSelector: [{ language: "marko" }],
documentSelector: [
{ scheme: "file", language: "marko" },
{ scheme: "untitled", language: "marko" },
],
synchronize: {
// Synchronize the setting section 'marko' to the server
configurationSection: "marko",
Expand Down

0 comments on commit 7a07f85

Please sign in to comment.