mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-03 07:04:34 +00:00
vscode: Request interesting buffers only
Ask VSCode to only send files stored on disc to the LSP, not random other kinds of buffers. The LS can not make sense of anything else anyway as it can nto get to the resources stored next to buffer it works on. For WASm we can load more kinds of buffers. Whitelist a range of possibnle buffer schemes, incl. `vscode-vfs` which is used on `github.dev`. This does stop VSCode from asking the LS to process random other buffers like those containing a git diff of a slint file. Fixes: #6375
This commit is contained in:
parent
40cd2cc8fe
commit
35cfed3a10
3 changed files with 28 additions and 3 deletions
|
@ -24,7 +24,25 @@ function startClient(
|
|||
//let args = vscode.workspace.getConfiguration('slint').get<[string]>('lsp-args');
|
||||
|
||||
// Options to control the language client
|
||||
const clientOptions = common.languageClientOptions(telemetryLogger);
|
||||
// Note: This works with way more schemes than the native LSP as it goes
|
||||
// through VSCode to open files by necessity.
|
||||
// https://github.com/microsoft/vscode/blob/main/src/vs/base/common/network.ts
|
||||
// lists all the known schemes in VSCode (without extensions). I err on the
|
||||
// side of allowing too much here I think...
|
||||
const clientOptions = common.languageClientOptions(
|
||||
[
|
||||
"file",
|
||||
"http",
|
||||
"https",
|
||||
"inmemory",
|
||||
"vscode-file",
|
||||
"vscode-remote",
|
||||
"vscode-remote-resource",
|
||||
"vscode-vfs", // github.dev uses this
|
||||
"vsls",
|
||||
],
|
||||
telemetryLogger,
|
||||
);
|
||||
clientOptions.synchronize = {};
|
||||
clientOptions.initializationOptions = {};
|
||||
|
||||
|
|
|
@ -100,10 +100,17 @@ export function setServerStatus(
|
|||
// as needed and makes the triggering side so much simpler!
|
||||
|
||||
export function languageClientOptions(
|
||||
schemes: string[],
|
||||
telemetryLogger: vscode.TelemetryLogger,
|
||||
): LanguageClientOptions {
|
||||
var document_selector = [];
|
||||
for (var scheme of schemes) {
|
||||
document_selector.push({ scheme: scheme, language: "slint" });
|
||||
document_selector.push({ scheme: scheme, language: "rust" });
|
||||
}
|
||||
|
||||
return {
|
||||
documentSelector: [{ language: "slint" }, { language: "rust" }],
|
||||
documentSelector: document_selector,
|
||||
middleware: {
|
||||
async provideCodeActions(
|
||||
document: vscode.TextDocument,
|
||||
|
|
|
@ -195,7 +195,7 @@ function startClient(
|
|||
"slint-lsp",
|
||||
"Slint",
|
||||
serverOptions,
|
||||
common.languageClientOptions(telemetryLogger),
|
||||
common.languageClientOptions(["file"], telemetryLogger),
|
||||
);
|
||||
|
||||
common.prepare_client(cl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue