Skip to content

Commit 3328901

Browse files
committed
fix: Incorrect cursor behavior in SQL Query Editor
1 parent 74ca16f commit 3328901

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

frontend/src/app/shared/components/code-editor/code-editor.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
(selectQuery)="writeValue($event)">
4141
</app-query-suggestions>
4242
<ngx-monaco-editor
43-
class="editor-area"
43+
class="editor-area pt-2"
4444
[options]="consoleOptions"
4545
[(ngModel)]="sqlQuery"
4646
(ngModelChange)="clearMessages()"

frontend/src/app/shared/components/code-editor/code-editor.component.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
flex: 1;
3535
overflow: hidden;
3636
border-bottom: 1px solid #e0e6ed;
37+
background-color: #fffffe;
3738

3839
.editor-area {
3940
height: 100%;
@@ -64,10 +65,6 @@
6465
color: #fff !important;
6566
}
6667

67-
::ng-deep .monaco-editor {
68-
padding-top: 10px;
69-
}
70-
7168
.monaco-editor .suggest-widget .codicon {
7269
display: none !important;
7370
}

frontend/src/app/shared/components/code-editor/code-editor.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ConsoleOptions {
2121
wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
2222
automaticLayout?: boolean;
2323
lineNumbers?: 'off' | 'on';
24+
cursorSmoothCaretAnimation?: 'off' | 'on';
2425
}
2526

2627
const SQL_KEYWORDS = ['CREATE', 'DROP', 'ALTER', 'TRUNCATE',
@@ -74,7 +75,8 @@ export class CodeEditorComponent implements OnInit, OnDestroy, ControlValueAcces
7475
overviewRulerLanes: 0,
7576
wordWrap: 'on',
7677
automaticLayout: true,
77-
lineNumbers: 'on'
78+
lineNumbers: 'on',
79+
cursorSmoothCaretAnimation: 'off'
7880
};
7981
private completionProvider?: monaco.IDisposable;
8082
private onChange = (_: any) => {};
@@ -93,7 +95,7 @@ export class CodeEditorComponent implements OnInit, OnDestroy, ControlValueAcces
9395
}
9496
}
9597

96-
onEditorInit(editor: monaco.editor.IStandaloneCodeEditor) {
98+
onEditorInit(editorInstance: monaco.editor.IStandaloneCodeEditor) {
9799
this.completionProvider = monaco.languages.registerCompletionItemProvider('sql', {
98100
provideCompletionItems: () => {
99101
const allKeywords = Array.from(new Set([
@@ -111,8 +113,8 @@ export class CodeEditorComponent implements OnInit, OnDestroy, ControlValueAcces
111113
}
112114
});
113115

114-
editor.onDidChangeModelContent(() => {
115-
const val = editor.getValue();
116+
editorInstance.onDidChangeModelContent(() => {
117+
const val = editorInstance.getValue();
116118
this.sqlQuery = val;
117119
this.onChange(val);
118120
this.onTouched();

0 commit comments

Comments
 (0)