mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-22 19:58:51 +00:00
fix(editor): stabilize SQL run-statement gutter width
This commit is contained in:
@@ -448,9 +448,9 @@ let tableReferenceDropListenerRegistered = false;
|
||||
let imeCompositionActive = false;
|
||||
let pendingImeModelEmit = false;
|
||||
|
||||
function runStatementGutterExtension(markers = props.statementExecutionMarkers ?? []): import("@codemirror/state").Extension {
|
||||
function runStatementGutterExtension(): import("@codemirror/state").Extension {
|
||||
const showRunButtons = !props.hideExecutionControls && settingsStore.editorSettings.showStatementRunButtons;
|
||||
return shouldShowStatementGutter(showRunButtons, markers.length) ? (buildRunStatementGutterExtension?.() ?? []) : [];
|
||||
return shouldShowStatementGutter(showRunButtons) ? (buildRunStatementGutterExtension?.() ?? []) : [];
|
||||
}
|
||||
|
||||
let executableStatementRangeCache: ExecutableStatementRangeCache | null = null;
|
||||
@@ -4785,15 +4785,6 @@ watch(
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.statementExecutionMarkers?.length ?? 0,
|
||||
() => {
|
||||
if (!view.value || !runGutterComp) return;
|
||||
// Remove the compartment entirely when controls and markers are absent so the editor keeps no empty gutter width.
|
||||
view.value.dispatch({ effects: runGutterComp.reconfigure(runStatementGutterExtension()) });
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.connectionId,
|
||||
() => {
|
||||
@@ -5195,7 +5186,7 @@ defineExpose({
|
||||
}
|
||||
|
||||
:deep(.cm-run-statement-gutter) {
|
||||
min-width: 34px;
|
||||
min-width: 28px;
|
||||
}
|
||||
|
||||
:deep(.cm-run-statement-gutter .cm-gutterElement) {
|
||||
@@ -5203,8 +5194,8 @@ defineExpose({
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
min-width: 34px;
|
||||
padding: 0 5px;
|
||||
min-width: 28px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
:deep(.cm-statement-execution-marker) {
|
||||
|
||||
@@ -4,10 +4,9 @@ import { describe, expect, it } from "vitest";
|
||||
import { createStatementGutterMarkerDom, shouldShowStatementGutter } from "@/lib/editor/codemirrorStatementGutter";
|
||||
|
||||
describe("CodeMirror statement gutter marker", () => {
|
||||
it("omits the gutter when run buttons and status markers are absent", () => {
|
||||
expect(shouldShowStatementGutter(false, 0)).toBe(false);
|
||||
expect(shouldShowStatementGutter(true, 0)).toBe(true);
|
||||
expect(shouldShowStatementGutter(false, 1)).toBe(true);
|
||||
it("keeps gutter visibility controlled by the run-button preference", () => {
|
||||
expect(shouldShowStatementGutter(false)).toBe(false);
|
||||
expect(shouldShowStatementGutter(true)).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps execution status inside the run button column", () => {
|
||||
|
||||
@@ -8,8 +8,8 @@ export interface StatementGutterMarkerDomOptions {
|
||||
statusLabel?: string;
|
||||
}
|
||||
|
||||
export function shouldShowStatementGutter(showRunButtons: boolean, markerCount: number): boolean {
|
||||
return showRunButtons || markerCount > 0;
|
||||
export function shouldShowStatementGutter(showRunButtons: boolean): boolean {
|
||||
return showRunButtons;
|
||||
}
|
||||
|
||||
function createStatusIconDom(status: StatementExecutionMarkerStatus, includeCircle: boolean) {
|
||||
|
||||
@@ -762,19 +762,19 @@ export function buildEditorFontThemeRules(opts?: { fixedHeight?: boolean; scroll
|
||||
},
|
||||
".cm-lineNumbers .cm-gutterElement": {
|
||||
cursor: "pointer",
|
||||
paddingRight: "16px",
|
||||
paddingRight: "8px",
|
||||
userSelect: "none",
|
||||
},
|
||||
".cm-run-statement-gutter": {
|
||||
minWidth: "34px",
|
||||
minWidth: "28px",
|
||||
},
|
||||
".cm-run-statement-gutter .cm-gutterElement": {
|
||||
alignItems: "center",
|
||||
boxSizing: "border-box",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
minWidth: "34px",
|
||||
padding: "0 5px",
|
||||
minWidth: "28px",
|
||||
padding: "0 2px",
|
||||
},
|
||||
".cm-run-statement-marker": {
|
||||
alignItems: "center",
|
||||
|
||||
Reference in New Issue
Block a user