Skip to content

Commit 1fcc091

Browse files
committed
fix: show inline completion between the words
1 parent d327d39 commit 1fcc091

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

packages/monaco-plugin-ob/example/src/components/App/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function () {
7272
delimiter: ';',
7373
llm: {
7474
async completions(input: string, pos: number) {
75-
return 'aaa1'
75+
return 'aaa1\naaaa\n'
7676
}
7777
},
7878
async getSnippets() {

packages/monaco-plugin-ob/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@oceanbase-odc/monaco-plugin-ob",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {

packages/monaco-plugin-ob/src/inlineCompletion/index.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,36 @@ class MonacoInlineComplete implements monaco.languages.InlineCompletionsProvider
4848
})
4949
return;
5050
}
51-
value = (currentToken?.word || '') + value
51+
52+
const start = model.getValueInRange({
53+
startLineNumber: position.lineNumber,
54+
startColumn: 0,
55+
endLineNumber: position.lineNumber,
56+
endColumn: position.column
57+
});
58+
const end = model.getValueInRange({
59+
startLineNumber: position.lineNumber,
60+
startColumn: position.column,
61+
endLineNumber: position.lineNumber + 1,
62+
endColumn: 0
63+
})
64+
let newValue = value;
65+
if (currentToken && currentToken.word) {
66+
newValue = start + value + end;
67+
} else {
68+
newValue = value + end;
69+
}
5270
resolve(
5371
{
5472
items: [
5573
{
56-
insertText: {
57-
snippet: value
74+
insertText: value,
75+
filterText: newValue,
76+
range: {
77+
startLineNumber: position.lineNumber,
78+
startColumn: position.column,
79+
endLineNumber: position.lineNumber,
80+
endColumn: position.column
5881
}
5982
}
6083
]

0 commit comments

Comments
 (0)