Skip to content

Commit

Permalink
(breaking) enable new transformation by default (#1633)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Sep 13, 2022
1 parent 7ee04e5 commit cb94f4b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/svelte-vscode/package.json
Expand Up @@ -271,10 +271,16 @@
},
"svelte.plugin.svelte.useNewTransformation": {
"type": "boolean",
"default": false,
"default": true,
"title": "Use a new transformation for intellisense",
"description": "Svelte files need to be transformed to something that TypeScript understands for intellisense. Version 2.0 of this transformation can be enabled with this setting. It will be the default, soon."
},
"svelte.plugin.svelte.note-new-transformation": {
"type": "boolean",
"default": true,
"title": "Show a note about the new transformation",
"description": "There's a new transformation for improved intellisense which is now turned on by default. This note notifies you about it."
},
"svelte.plugin.svelte.diagnostics.enable": {
"type": "boolean",
"default": true,
Expand Down
47 changes: 47 additions & 0 deletions packages/svelte-vscode/src/extension.ts
Expand Up @@ -223,6 +223,24 @@ export function activateSvelteLanguageServer(context: ExtensionContext) {
return ls;
}

noteOfNewTransformation();
let enabled = workspace
.getConfiguration('svelte.plugin.svelte')
.get<boolean>('useNewTransformation');
context.subscriptions.push(
workspace.onDidChangeConfiguration(() => {
if (
enabled !==
workspace
.getConfiguration('svelte.plugin.svelte')
.get<boolean>('useNewTransformation')
) {
enabled = !enabled;
restartLS(false);
}
})
);

addDidChangeTextDocumentListener(getLS);

addFindFileReferencesListener(getLS, context);
Expand Down Expand Up @@ -488,3 +506,32 @@ function warnIfOldExtensionInstalled() {
);
}
}

async function noteOfNewTransformation() {
const enabled = workspace
.getConfiguration('svelte.plugin.svelte')
.get<boolean>('useNewTransformation');
const shouldNote = workspace
.getConfiguration('svelte.plugin.svelte')
.get<boolean>('note-new-transformation');
if (!enabled || !shouldNote) {
return;
}

const answers = ['Ask again later', 'Disable new transformation for now', 'OK'];
const response = await window.showInformationMessage(
'The Svelte for VS Code extension comes with a new transformation for improved intellisense. ' +
'It is enabled by default now. If you notice bugs, please report them. ' +
'You can switch to the old transformation setting "svelte.plugin.svelte.useNewTransformation" to "false".',
...answers
);

if (response === answers[1]) {
workspace
.getConfiguration('svelte.plugin.svelte')
.update('useNewTransformation', false, true);
}
workspace
.getConfiguration('svelte.plugin.svelte')
.update('note-new-transformation', response === answers[0], true);
}

0 comments on commit cb94f4b

Please sign in to comment.