mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 21:55:59 +00:00
code completion context is only current query
This commit is contained in:
@@ -96,6 +96,11 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCodeCompletionCommandText() {
|
||||||
|
if (currentPart != null) return currentPart.text;
|
||||||
|
return editor.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
const requireEditorPlugins = () => {};
|
const requireEditorPlugins = () => {};
|
||||||
requireEditorPlugins();
|
requireEditorPlugins();
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,12 @@
|
|||||||
$: effect = useEffect(() => {
|
$: effect = useEffect(() => {
|
||||||
const editor = domEditor?.getEditor();
|
const editor = domEditor?.getEditor();
|
||||||
if ($tabVisible && conid && database && !readOnly && editor) {
|
if ($tabVisible && conid && database && !readOnly && editor) {
|
||||||
return mountCodeCompletion({ conid, database, editor });
|
return mountCodeCompletion({
|
||||||
|
conid,
|
||||||
|
database,
|
||||||
|
editor,
|
||||||
|
getText: () => domEditor.getCodeCompletionCommandText(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return () => {};
|
return () => {};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const COMMON_KEYWORDS = [
|
|||||||
'go',
|
'go',
|
||||||
];
|
];
|
||||||
|
|
||||||
export function mountCodeCompletion({ conid, database, editor }) {
|
export function mountCodeCompletion({ conid, database, editor, getText }) {
|
||||||
setCompleters([]);
|
setCompleters([]);
|
||||||
addCompleter({
|
addCompleter({
|
||||||
getCompletions: async function (editor, session, pos, prefix, callback) {
|
getCompletions: async function (editor, session, pos, prefix, callback) {
|
||||||
@@ -44,7 +44,7 @@ export function mountCodeCompletion({ conid, database, editor }) {
|
|||||||
const lastKeywordMatch = line.match(/([a-zA-Z0-9_]*)\s*$/);
|
const lastKeywordMatch = line.match(/([a-zA-Z0-9_]*)\s*$/);
|
||||||
const lastKeyword = lastKeywordMatch ? lastKeywordMatch[1].toUpperCase().trim() : '';
|
const lastKeyword = lastKeywordMatch ? lastKeywordMatch[1].toUpperCase().trim() : '';
|
||||||
|
|
||||||
const sources = analyseQuerySources(editor.getValue(), [
|
const sources = analyseQuerySources(getText(), [
|
||||||
...dbinfo.tables.map(x => x.pureName),
|
...dbinfo.tables.map(x => x.pureName),
|
||||||
...dbinfo.views.map(x => x.pureName),
|
...dbinfo.views.map(x => x.pureName),
|
||||||
...dbinfo.matviews.map(x => x.pureName),
|
...dbinfo.matviews.map(x => x.pureName),
|
||||||
|
|||||||
Reference in New Issue
Block a user