Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Aug 17, 2024
1 parent d1c4736 commit a774b30
Show file tree
Hide file tree
Showing 15 changed files with 907 additions and 898 deletions.
8 changes: 3 additions & 5 deletions packages/language-server/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ export function createConnection() {

export function createServer(connection: vscode.Connection) {
const server = createServerBase(connection);
server.onInitialize(() => {
server.features.fileSystem.install('http', httpFsProvider);
server.features.fileSystem.install('https', httpFsProvider);
setServer(server);
});
server.fileSystem.install('http', httpFsProvider);
server.fileSystem.install('https', httpFsProvider);
setServer(server);
return server;
}

Expand Down
31 changes: 15 additions & 16 deletions packages/language-server/lib/features/configurations.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import * as vscode from 'vscode-languageserver';
import { LanguageServerState } from '../types';

export function register(
connection: vscode.Connection,
initializeParams: vscode.InitializeParams
) {
export function register(server: LanguageServerState) {
const configurations = new Map<string, Promise<any>>();
const didChangeCallbacks = new Set<vscode.NotificationHandler<vscode.DidChangeConfigurationParams>>();

let registered = false;

connection.onDidChangeConfiguration(params => {
configurations.clear(); // TODO: clear only the configurations that changed
for (const cb of didChangeCallbacks) {
cb(params);
server.onInitialized(() => {
server.connection.onDidChangeConfiguration(params => {
configurations.clear(); // TODO: clear only the configurations that changed
for (const cb of didChangeCallbacks) {
cb(params);
}
});
const didChangeConfiguration = server.initializeParams.capabilities.workspace?.didChangeConfiguration;
if (didChangeConfiguration?.dynamicRegistration) {
server.connection.client.register(vscode.DidChangeConfigurationNotification.type);
}
});

Expand All @@ -22,17 +24,14 @@ export function register(
};

function get<T>(section: string, scopeUri?: string): Promise<T | undefined> {
if (!initializeParams.capabilities.workspace?.configuration) {
if (!server.initializeParams.capabilities.workspace?.configuration) {
return Promise.resolve(undefined);
}
const didChangeConfiguration = initializeParams.capabilities.workspace?.didChangeConfiguration;
const didChangeConfiguration = server.initializeParams.capabilities.workspace?.didChangeConfiguration;
if (!scopeUri && didChangeConfiguration) {
if (!configurations.has(section)) {
configurations.set(section, getConfigurationWorker(section, scopeUri));
}
if (!registered && didChangeConfiguration.dynamicRegistration) {
connection.client.register(vscode.DidChangeConfigurationNotification.type);
}
return configurations.get(section)!;
}
return getConfigurationWorker(section, scopeUri);
Expand All @@ -48,6 +47,6 @@ export function register(
}

async function getConfigurationWorker(section: string, scopeUri?: string) {
return (await connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
return (await server.connection.workspace.getConfiguration({ scopeUri, section })) ?? undefined /* replace null to undefined */;
}
}
Loading

0 comments on commit a774b30

Please sign in to comment.