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

fix: remove unexpected endsubmit autocomplete #1359

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,80 +148,81 @@ export const runServer = (
) {
return undefined;
}
const complitionList =
const completionList =
await languageService.completionProvider.getCompleteItems(
params.position,
);
if (complitionList) {
for (const item of complitionList.items) {
if (completionList) {
for (const item of completionList.items) {
if (!item.data) {
item.data = {};
}
item.data._languageService = "sas";
item.data._uri = params.textDocument.uri;
}
}
return complitionList;
return completionList;
},
async python(pyrightLanguageService) {
const complitionList = await pyrightLanguageService.onCompletion(
const completionList = await pyrightLanguageService.onCompletion(
params,
token,
);
if (complitionList) {
if (completionList) {
for (const item of completionList.items) {
if (!item.data) {
item.data = {};
}
item.data._languageService = "python";
item.data._uri = params.textDocument.uri;
}

if (
params.context?.triggerKind === CompletionTriggerKind.Invoked ||
params.context?.triggerKind ===
CompletionTriggerKind.TriggerForIncompleteCompletions
) {
if (
complitionList.items.findIndex(
(item) => item.label === "endsubmit",
) === -1
) {
const endsubmitItem = {
insertText: undefined,
kind: CompletionItemKind.Keyword,
label: "endsubmit",
};
complitionList.items.push(endsubmitItem);
}
if (
complitionList.items.findIndex(
(item) => item.label === "endinteractive",
) === -1
) {
const endinteractiveItem = {
insertText: undefined,
const doc = documentPool[params.textDocument.uri].document;
const line = doc.getText({
start: {
line: params.position.line,
character: 0,
},
end: params.position,
});
if (!/\W/.test(line.trimStart())) {
const item = {
kind: CompletionItemKind.Keyword,
label: "endinteractive",
data: {
_languageService: "sas",
_uri: params.textDocument.uri,
},
};
complitionList.items.push(endinteractiveItem);
}
}
for (const item of complitionList.items) {
if (!item.data) {
item.data = {};
if (
completionList.items.findIndex(
(item) => item.label === "endsubmit",
) === -1
) {
completionList.items.push({ ...item, label: "endsubmit" });
}
if (
completionList.items.findIndex(
(item) => item.label === "endinteractive",
) === -1
) {
completionList.items.push({ ...item, label: "endinteractive" });
}
}
item.data._languageService = "python";
item.data._uri = params.textDocument.uri;
}
}
return complitionList;
return completionList;
},
});
});

connection.onCompletionResolve(async (completionItem, token) => {
const lang = completionItem.data._languageService;
const label = completionItem.label;
const kind = completionItem.kind;
if (
lang === "sas" ||
(lang === "python" &&
kind === CompletionItemKind.Keyword &&
["endsubmit", "endinteractive"].includes(label?.toLowerCase()))
) {
if (lang === "sas") {
const languageService = getLanguageService(completionItem.data._uri);
return await languageService.completionProvider.getCompleteItemHelp(
completionItem,
Expand All @@ -231,9 +232,8 @@ export const runServer = (
completionItem,
token,
);
} else {
return completionItem;
}
return completionItem;
});

connection.onDocumentSymbol(async (params, token) => {
Expand Down
Loading