Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import util::Reflective;
extend lang::pico::\syntax::Main;
import DateTime;
import IO;
import List;
import Location;
import String;

Expand Down Expand Up @@ -317,7 +318,7 @@ list[CompletionItem] picoCompletionService(Focus focus, int cursorOffset, Comple
t = focus[0];
str prefix = "<t>"[..cursorOffset];
cc = t.src.begin.column + cursorOffset;
items = [];
list[CompletionItem] items = [];

isTypingId = false;
try {
Expand All @@ -339,7 +340,7 @@ list[CompletionItem] picoCompletionService(Focus focus, int cursorOffset, Comple
}
}

return items;
return sort(items, bool(CompletionItem i1, CompletionItem i2) {return i1.label < i2.label; });
}

@synopsis{The main function registers the Pico language with the IDE}
Expand Down
4 changes: 2 additions & 2 deletions rascal-vscode-extension/src/test/vscode-suite/dsl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ end

await editor.moveCursor(9, 4);
await bench.executeCommand("editor.action.triggerSuggest"); // 'completion', typically triggered with Ctrl+Space
expectCompletions(editor, ["a", "aa"]);
await expectCompletions(driver, editor, ["a", "aa"]);
});

it("completion by trigger character works", async function() {
Expand All @@ -322,7 +322,7 @@ end
const editor = await ide.openModule(TestWorkspace.picoFile);
await editor.moveCursor(10, 10);
await editor.typeText(" x :=");
expectCompletions(editor, ["x", "n", "a", "b"]);
await expectCompletions(driver, editor, ["a", "b", "n", "x"]);
});

it("serializes Rascal values as expected", async function() {
Expand Down
13 changes: 8 additions & 5 deletions rascal-vscode-extension/src/test/vscode-suite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,13 @@ export function printRascalOutputOnFailure(channel: 'Language Parametric Rascal'
});
}

export async function expectCompletions(editor: TextEditor, expectedLabels: string[]) {
const completionMenu = new ContentAssist(editor);
const completions = await completionMenu.getItems();
export async function expectCompletions(driver: WebDriver, editor: TextEditor, expectedLabels: string[]) {
const completions = await driver.wait(async () => {
const completionMenu = new ContentAssist(editor);
return await ignoreFails(completionMenu.getItems());
}, Delays.fast, "Completion items not found");

expect(completions).to.have.length(expectedLabels.length);
const labels: string[] = await Promise.all(completions.map(c => c.getLabel()));
expect(labels).to.deep.equal(expectedLabels);
const labels: string[] = await Promise.all(completions!.map(c => c.getLabel()));
expect(labels).deep.equal(expectedLabels);
}
Loading