Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(sql-editor): active range (#15431)

boojack6ba0e75f45ad
diff --git a/frontend/src/components/MonacoEditor/MonacoEditor.vue b/frontend/src/components/MonacoEditor/MonacoEditor.vue
index 4719a5c008..e3044c4fdf 100644
--- a/frontend/src/components/MonacoEditor/MonacoEditor.vue
+++ b/frontend/src/components/MonacoEditor/MonacoEditor.vue
@@ -118,41 +118,20 @@ const activeRangeByCursor = computed((): IRange | undefined => {
return range;
});
-const activeRange = computed((): IRange | undefined => {
- const rangeByCursor = activeRangeByCursor.value;
- const rangeBySelection = activeSelection.value;
-
- if (!rangeBySelection) {
- return rangeByCursor;
- }
- if (
- rangeBySelection.startLineNumber === rangeBySelection.endLineNumber &&
- rangeBySelection.startColumn === rangeBySelection.endColumn
- ) {
- // Means no selection, just active cursor.
- return rangeByCursor;
- }
+const hasSelection = computed(() => {
+ return (
+ activeSelection.value &&
+ (activeSelection.value.startLineNumber !==
+ activeSelection.value.endLineNumber ||
+ activeSelection.value.startColumn !== activeSelection.value.endColumn)
+ );
+});
- if (!rangeByCursor) {
- return rangeBySelection;
+const activeRange = computed((): IRange | null | undefined => {
+ if (!hasSelection.value) {
+ return activeRangeByCursor.value;
}
-
- // Calculate the maximum range
- return {
- startLineNumber: Math.min(
- rangeByCursor.startLineNumber,
- rangeBySelection.startLineNumber
- ),
- startColumn: Math.min(
- rangeByCursor.startColumn,
- rangeBySelection.startColumn
- ),
- endLineNumber: Math.max(
- rangeByCursor.endLineNumber,
- rangeBySelection.endLineNumber
- ),
- endColumn: Math.max(rangeByCursor.endColumn, rangeBySelection.endColumn),
- };
+ return activeSelection.value;
});
const oldDecorationsCollection = ref<editor.IEditorDecorationsCollection>();
@@ -163,15 +142,8 @@ watch(activeRange, () => {
}
oldDecorationsCollection.value?.clear();
- if (!activeRange.value) {
- return;
- }
- if (
- activeSelection.value &&
- (activeSelection.value.startLineNumber !==
- activeSelection.value.endLineNumber ||
- activeSelection.value.startColumn !== activeSelection.value.endColumn)
- ) {
+ // Has manual selection or no active range, do not highlight.
+ if (hasSelection.value || !activeRange.value) {
return;
}