Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(language-server): remove fullCompletionList init option #139

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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