Skip to content

Commit

Permalink
fix(plugin-sql-editor): CB-1106 autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed Jul 10, 2021
1 parent 255598a commit adb6881
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ export class SqlEditorController implements IInitializableController {
return;
}

if (this.editor.state.completionActive) {
if (
this.editor.state.completionActive
&& this.editor.state.completionActive.options.completeSingle === !activeSuggest
) {
this.editor.state.completionActive.update();
return;
}
Expand Down Expand Up @@ -272,8 +275,17 @@ export class SqlEditorController implements IInitializableController {
let closedByCursor = false;
let cursor: Position | null = null;

editor.on('changes', () => {
if (this.activeSuggest && !editor.state.completionActive && !closedByCursor) {
const ignoredChanges = ['+delete', 'undo'];

editor.on('changes', (cm, changes) => {
const lastChange = changes[changes.length - 1];

if (
this.activeSuggest
&& !editor.state.completionActive
&& !closedByCursor
&& (!lastChange.origin || !ignoredChanges.includes(lastChange.origin))
) {
cursor = editor.getCursor('from');
this.showHint(true);
}
Expand Down

0 comments on commit adb6881

Please sign in to comment.