mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Updated multi root example to API changes
This commit is contained in:
@ -13,7 +13,7 @@ let clients: Map<string, LanguageClient> = new Map();
|
||||
function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
|
||||
let result = folder;
|
||||
let candidate: WorkspaceFolder;
|
||||
while((candidate = Workspace.getWorkspaceFolder(folder.uri)) !== void 0) {
|
||||
while((candidate = Workspace.getWorkspaceFolder(folder.uri)) !== folder) {
|
||||
result = candidate;
|
||||
}
|
||||
return result;
|
||||
@ -51,7 +51,7 @@ export function activate(context: ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
let folder = Workspace.getWorkspaceFolder(uri);
|
||||
// Files outside a folder can't be handled. This might depend on the language
|
||||
// Files outside a folder can't be handled. This might depend on the language.
|
||||
// Single file languages like JSON might handle files outside the workspace folders.
|
||||
if (!folder) {
|
||||
return;
|
||||
|
||||
@ -7,18 +7,23 @@ import {
|
||||
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
|
||||
} from 'vscode-languageserver';
|
||||
|
||||
// Creates the LSP connection
|
||||
let connection = createConnection(ProposedFeatures.all);
|
||||
// Create a manager for open text documents
|
||||
|
||||
let documents = new TextDocuments();
|
||||
let rootUri: string;
|
||||
|
||||
// The workspace folder this server is operating on
|
||||
let workspaceFolder: string;
|
||||
|
||||
documents.onDidOpen((event) => {
|
||||
connection.console.log(`[Server ${rootUri}] Document opened: ${event.document.uri}`);
|
||||
connection.console.log(`[Server ${workspaceFolder}] Document opened: ${event.document.uri}`);
|
||||
})
|
||||
documents.listen(connection);
|
||||
|
||||
connection.onInitialize((params) => {
|
||||
rootUri = params.rootUri;
|
||||
connection.console.log(`Server started for folder: ${rootUri}`);
|
||||
workspaceFolder = params.rootUri;
|
||||
connection.console.log(`Server started for folder: ${workspaceFolder}`);
|
||||
return {
|
||||
capabilities: {
|
||||
textDocumentSync: {
|
||||
|
||||
Reference in New Issue
Block a user