Skip to content

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

feat: update untitled handling (#1385)

Matthew Espinoe286783a811c
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index 952c25450..cac21c896 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -105,6 +105,14 @@ impl Backend {
}
async fn load_ignored_lints(&self, uri: &Uri) -> Result<IgnoredLints> {
+ // VS Code's unsaved documents have "untitled" scheme
+ if uri
+ .scheme()
+ .is_some_and(|scheme| scheme.eq_lowercase("untitled"))
+ {
+ return Ok(IgnoredLints::new());
+ }
+
Ok(load_ignored_lints(
self.get_ignored_lints_path(uri)
.await
diff --git a/packages/vscode-plugin/src/extension.ts b/packages/vscode-plugin/src/extension.ts
index 69098e844..f130a8fa7 100644
--- a/packages/vscode-plugin/src/extension.ts
+++ b/packages/vscode-plugin/src/extension.ts
@@ -30,15 +30,11 @@ const clientOptions: LanguageClientOptions = {
},
executeCommand(command, args, next) {
if (
- ['HarperAddToUserDict', 'HarperAddToFileDict'].includes(command) &&
+ ['HarperAddToUserDict', 'HarperAddToFileDict', 'HarperIgnoreLint'].includes(command) &&
args.find((a) => typeof a === 'string' && a.startsWith('untitled:'))
) {
window
- .showInformationMessage(
- 'Save the file to add words to the dictionary.',
- 'Save File',
- 'Dismiss',
- )
+ .showInformationMessage('Save the file to execute this command.', 'Save File', 'Dismiss')
.then((selected) => {
if (selected === 'Save File') {
commands.executeCommand('workbench.action.files.save');