mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Update the example to demo server side for workspace folder change events
This commit is contained in:
@ -17,6 +17,7 @@ let connection = createConnection(ProposedFeatures.all);
|
||||
let documents: TextDocuments = new TextDocuments();
|
||||
|
||||
let hasConfigurationCapability = false;
|
||||
let hasWorkspaceFolderCapability = false;
|
||||
|
||||
connection.onInitialize((params: InitializeParams) => {
|
||||
function hasClientCapability(...keys: string[]) {
|
||||
@ -29,6 +30,7 @@ connection.onInitialize((params: InitializeParams) => {
|
||||
// Does the client support the `workspace/configuration` request?
|
||||
// If not, we will fall back using global settings
|
||||
hasConfigurationCapability = hasClientCapability('workspace', 'configuration');
|
||||
hasWorkspaceFolderCapability = hasClientCapability('workspace', 'workspaceFolders');
|
||||
return {
|
||||
capabilities: {
|
||||
textDocumentSync: documents.syncKind
|
||||
@ -36,6 +38,14 @@ connection.onInitialize((params: InitializeParams) => {
|
||||
}
|
||||
});
|
||||
|
||||
connection.onInitialized(() => {
|
||||
if (hasWorkspaceFolderCapability) {
|
||||
connection.workspace.onDidChangeWorkspaceFolders((_event) => {
|
||||
connection.console.log('Workspace folder change event received');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// The example settings
|
||||
interface MultiRootExampleSettings {
|
||||
maxNumberOfProblems: number;
|
||||
|
||||
Reference in New Issue
Block a user