Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(breaking) enable new transformation by default #1633

Merged
merged 1 commit into from
Sep 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/svelte-vscode/package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
}