Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
refactor: update
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Feb 10, 2020
1 parent faf76c9 commit 4098c00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
23 changes: 14 additions & 9 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ interface SynchronizedConfiguration {
enable?: boolean;
dtsFilepaths?: string[];
import_map?: string;
// external
workspaceDir?: string;
}

interface TypescriptAPI {
configurePlugin(pluginId: string, configuration: {}): void;
configurePlugin(
pluginId: string,
configuration: SynchronizedConfiguration
): void;
}

interface DenoInfo {
Expand Down Expand Up @@ -219,12 +220,6 @@ class Extension {
config.enable = false;
}

const workspaceFolder = workspace.getWorkspaceFolder(uri);

if (workspaceFolder) {
config.workspaceDir = workspaceFolder.uri.fsPath;
}

return config;
}
// register command for deno extension
Expand Down Expand Up @@ -313,6 +308,9 @@ class Extension {
progressOnInitialization: true,
middleware: {
provideCodeActions: (document, range, context, token, next) => {
if (!this.getConfiguration(document.uri).enable) {
return [];
}
// do not ask server for code action when the diagnostic isn't from deno
if (!context.diagnostics || context.diagnostics.length === 0) {
return [];
Expand All @@ -330,6 +328,13 @@ class Extension {
diagnostics: denoDiagnostics
} as CodeActionContext);
return next(document, range, newContext, token);
},
provideCompletionItem: (document, position, context, token, next) => {
if (!this.getConfiguration(document.uri).enable) {
return [];
}

return next(document, position, context, token);
}
}
};
Expand Down
8 changes: 0 additions & 8 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ connection.onDocumentFormatting(async params => {
return [TextEdit.replace(range, formatted)];
});

// FIXME: all completion will trigger this.
// It seem it's a bug for vscode
connection.onCompletion(async params => {
const { position, partialResultToken, textDocument } = params;

Expand All @@ -148,12 +146,6 @@ connection.onCompletion(async params => {
return [];
}

const config = await bridge.getWorkspaceConfig(doc.uri);

if (!config.enable) {
return [];
}

const currentLine = doc.getText(
Range.create(Position.create(position.line, 0), position)
);
Expand Down

0 comments on commit 4098c00

Please sign in to comment.