Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(vscode-plugin): add support for untitled scheme

Donny Kimaa05fabe3dcd
diff --git a/packages/vscode-plugin/src/extension.ts b/packages/vscode-plugin/src/extension.ts
index c6f9c9aef..ecae425ae 100644
--- a/packages/vscode-plugin/src/extension.ts
+++ b/packages/vscode-plugin/src/extension.ts
@@ -31,7 +31,13 @@ export async function activate(context: ExtensionContext): Promise<void> {
clientOptions.documentSelector = manifest.activationEvents
.filter((e) => e.startsWith('onLanguage:'))
- .map((e) => ({ language: e.split(':')[1], scheme: 'file' }));
+ .flatMap((e) => {
+ const language = e.split(':')[1];
+ return [
+ { language, scheme: 'file' },
+ { language, scheme: 'untitled' }
+ ];
+ });
clientOptions.outputChannel = window.createOutputChannel('Harper');
context.subscriptions.push(clientOptions.outputChannel);
diff --git a/packages/vscode-plugin/src/tests/suite/integration.test.ts b/packages/vscode-plugin/src/tests/suite/integration.test.ts
index 7aebc3db8..be877f2be 100644
--- a/packages/vscode-plugin/src/tests/suite/integration.test.ts
+++ b/packages/vscode-plugin/src/tests/suite/integration.test.ts
@@ -45,12 +45,18 @@ describe('Integration >', () => {
);
});
- it('does nothing for untitled', async () => {
+ it('gives correct diagnostics for untitled', async () => {
const untitledUri = await openUntitled('Errorz');
+ // Wait for `harper-ls` to send diagnostics
+ await sleep(500);
+
compareActualVsExpectedDiagnostics(
getActualDiagnostics(untitledUri),
- createExpectedDiagnostics()
+ createExpectedDiagnostics({
+ message: 'Did you mean to spell “Errorz” this way?',
+ range: createRange(0, 0, 0, 6)
+ })
);
});