Skip to content

Commit

Permalink
refactor(language-server): remove fullCompletionList init option (#139
Browse files Browse the repository at this point in the history
)
  • Loading branch information
johnsoncodehk committed Feb 20, 2024
1 parent 5fd194b commit fadba59
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import * as embedded from '@volar/language-service';
import type { SnapshotDocument } from '@volar/snapshot-document';
import * as vscode from 'vscode-languageserver';
import { AutoInsertRequest, FindFileReferenceRequest } from '../../protocol';
import type { InitializationOptions, ServerProjectProvider, ServerRuntimeEnvironment } from '../types';
import type { ServerProjectProvider, ServerRuntimeEnvironment } from '../types';

export function registerLanguageFeatures(
connection: vscode.Connection,
projectProvider: ServerProjectProvider,
initParams: vscode.InitializeParams,
initOptions: InitializationOptions,
semanticTokensLegend: vscode.SemanticTokensLegend,
runtime: ServerRuntimeEnvironment,
documents: vscode.TextDocuments<SnapshotDocument>,
) {

let lastCompleteUri: string;
Expand Down Expand Up @@ -72,7 +69,6 @@ export function registerLanguageFeatures(
return worker(params.textDocument.uri, token, async service => {
lastCompleteUri = params.textDocument.uri;
lastCompleteLs = service;
const document = documents.get(params.textDocument.uri);
const list = await service.doComplete(
params.textDocument.uri,
params.position,
Expand All @@ -82,33 +78,6 @@ export function registerLanguageFeatures(
for (const item of list.items) {
fixTextEdit(item);
}
if (!initOptions.fullCompletionList && document) {
list.items = list.items.filter(item => {
const range = item.textEdit ? (
vscode.InsertReplaceEdit.is(item.textEdit)
? item.textEdit.replace
: item.textEdit.range
) : list.itemDefaults?.editRange ? (
vscode.Range.is(list.itemDefaults.editRange)
? list.itemDefaults.editRange
: list.itemDefaults.editRange.replace
) : undefined;
if (range) {
const sourceText = document.getText(range).toLowerCase();
if (sourceText.trim()) {
let filterText = (item.filterText ?? item.label).toLowerCase();
for (const char of sourceText) {
const index = filterText.indexOf(char);
if (index === -1) {
return false;
}
filterText = filterText.slice(index + 1);
}
}
}
return true;
});
}
return list;
});
});
Expand Down
2 changes: 0 additions & 2 deletions packages/language-server/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ export function createServerBase(
connection,
projects,
params,
context.initializeParams.initializationOptions ?? {},
getSemanticTokensLegend(),
context.runtimeEnv,
documents,
);

try {
Expand Down
6 changes: 0 additions & 6 deletions packages/language-server/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ export interface InitializationOptions {
location: string; // uri
};
diagnosticModel?: DiagnosticModel;
/**
* For better JSON parsing performance language server will filter CompletionList.
*
* Enable this option if you want to get complete CompletionList in language client.
*/
fullCompletionList?: boolean;
// for resolve https://github.com/sublimelsp/LSP-volar/issues/114
ignoreTriggerCharacters?: string[];
reverseConfigFilePriority?: boolean;
Expand Down

0 comments on commit fadba59

Please sign in to comment.