mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where Autocomplete did not work after pressing CTRL/CMD + Space
for the second time and autocomplete on keypress is off. Fixes #7563
This commit is contained in:
parent
1745aaaa0a
commit
3e3f06c55d
@ -27,7 +27,7 @@ const useStyles = makeStyles(()=>({
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function registerAutocomplete(api, transId, onFailure) {
|
function registerAutocomplete(api, transId, sqlEditorPref, onFailure) {
|
||||||
let timeoutId;
|
let timeoutId;
|
||||||
let loadingEle;
|
let loadingEle;
|
||||||
let autoCompleteList = [];
|
let autoCompleteList = [];
|
||||||
@ -170,11 +170,16 @@ function registerAutocomplete(api, transId, onFailure) {
|
|||||||
search = search.slice(1);
|
search = search.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handled special case when autocomplete on keypress is off,
|
||||||
|
// the query is cleared, and retype some other words and press CTRL/CMD + Space.
|
||||||
|
if (!sqlEditorPref.autocomplete_on_key_press && start == 0)
|
||||||
|
autoCompleteList = [];
|
||||||
|
|
||||||
// Clear the auto complete list if previous token/search is blank or dot.
|
// Clear the auto complete list if previous token/search is blank or dot.
|
||||||
prevSearch = search;
|
|
||||||
if (prevSearch == '' || prevSearch == '.')
|
if (prevSearch == '' || prevSearch == '.')
|
||||||
autoCompleteList = [];
|
autoCompleteList = [];
|
||||||
|
|
||||||
|
prevSearch = search;
|
||||||
// Get the text from start to the current cursor position.
|
// Get the text from start to the current cursor position.
|
||||||
self_local.data.push(
|
self_local.data.push(
|
||||||
doc.getRange({
|
doc.getRange({
|
||||||
@ -459,9 +464,9 @@ export default function Query() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
registerAutocomplete(queryToolCtx.api, queryToolCtx.params.trans_id, (err)=>{
|
registerAutocomplete(queryToolCtx.api, queryToolCtx.params.trans_id, queryToolCtx.preferences.sqleditor,
|
||||||
eventBus.fireEvent(QUERY_TOOL_EVENTS.HANDLE_API_ERROR, err);
|
(err)=>{eventBus.fireEvent(QUERY_TOOL_EVENTS.HANDLE_API_ERROR, err);}
|
||||||
});
|
);
|
||||||
}, [queryToolCtx.params.trans_id]);
|
}, [queryToolCtx.params.trans_id]);
|
||||||
|
|
||||||
const isDirty = ()=>(queryToolCtx.params.is_query_tool && lastSavedText.current !== editor.current.getValue());
|
const isDirty = ()=>(queryToolCtx.params.is_query_tool && lastSavedText.current !== editor.current.getValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user