Skip to content

Commit cd2dc39

Browse files
committed
Change @... completion items
In addition to removing the _SYMBOL appendix also convert the AT_ prefix to @. Change-Id: I97179084043f1177a958e11d57ca2450df15707b
1 parent b9d8f94 commit cd2dc39

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

gui/frontend/src/parsing/mysql/MySQLCodeCompletion.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,11 @@ export const getCodeCompletionItems = (caretLine: number, caretOffset: number, d
695695
entry = unquote(entry);
696696
}
697697

698+
// Second step to build a usable entry string is to check for certain MRS tokens, which start with `AT_`.
699+
if (entry.startsWith("AT_")) {
700+
entry = "@" + entry.substring(3);
701+
}
702+
698703
let isFunction = false;
699704
if (candidate[1].length > 0) {
700705
// A function call?

gui/frontend/src/parsing/worker/RdbmsLanguageService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,27 @@ export class RdbmsLanguageService {
144144

145145
this.pool.runTask(infoData).then((taskId: number, result: ILanguageWorkerResultData): void => {
146146
if (!model.isDisposed() && result.completions) {
147-
const info = model.getWordUntilPosition(position);
147+
// Determine what has been written so far, by going back from the current position until we find
148+
// a whitespace character or the start of the line.
149+
const line = model.getLineContent(position.lineNumber);
150+
let index = position.column - 1;
151+
while (index > 0 && !/\s/.test(line[index - 1])) {
152+
--index;
153+
}
154+
148155
const replaceRange = context.fromLocal({
149156
startLineNumber: position.lineNumber,
150-
startColumn: info.startColumn,
157+
startColumn: index + 1,
151158
endLineNumber: position.lineNumber,
152-
endColumn: info.endColumn,
159+
endColumn: position.column,
153160
});
154161

155162
this.transformCompletionItems(result.completions, replaceRange).then((suggestions) => {
156163
if (suggestions.length === 0) {
157164
// Add a special item here if nothing was found.
158165
// Otherwise we get some meaningless default suggestions.
159166
suggestions.push({
160-
label: "No Suggestions.",
167+
label: "No Suggestions",
161168
kind: languages.CompletionItemKind.Text,
162169
range: replaceRange,
163170
insertText: "",

0 commit comments

Comments
 (0)