Skip to content

Commit fcb0da9

Browse files
committed
fix: set correct offset
1 parent fd43c13 commit fcb0da9

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,27 @@ export default function () {
7272
delimiter: ';',
7373
llm: {
7474
async completions(input: string, pos: number) {
75-
return 'aaa1\naaaa\n'
75+
// input 的 pos 位置增加一个光标
76+
const cursor = input.slice(0, pos) + '|' + input.slice(pos);
77+
const res = await fetch('http://localhost/v1/workflows/run', {
78+
method: 'POST',
79+
headers: {
80+
"Authorization": `Bearer app-XyQfvJ9VFtm58VLquEMNHUmO`,
81+
"Content-Type": 'application/json'
82+
},
83+
body: JSON.stringify({
84+
user: 'shankar',
85+
response_mode: "blocking",
86+
inputs: {
87+
sql: cursor,
88+
currentDatabase: 'dbgpt'
89+
}
90+
})
91+
})
92+
const data = await res.json();
93+
const sql = data.data?.outputs?.sql || '';
94+
console.log(sql);
95+
return sql;
7696
}
7797
},
7898
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.4.0",
3+
"version": "1.4.1",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {

packages/monaco-plugin-ob/src/obmysql/worker/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ export default {
348348
if (!statement) {
349349
return null;
350350
}
351+
offset = offset - statement.start;
351352
const result = statement.parse(offset, () => {});
352353
if (!result){
353354
return null;

0 commit comments

Comments
 (0)