feat(editor): add scroll space past last line

This commit is contained in:
greathaoqi authored and GitHub committed 2026-07-27 19:14:24 +08:00
1 parent a49137ae8b
commit 1748638a55
2 files changed
+13 -1

No files matched your search

@@ -3246,7 +3246,7 @@ onMounted(async () => {
if (!editorRef.value) return;
const [
{ EditorView, keymap, rectangularSelection, hoverTooltip, showTooltip, Decoration, tooltips, gutter, GutterMarker, lineNumberMarkers, lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, crosshairCursor, ViewPlugin },
{ EditorView, keymap, rectangularSelection, hoverTooltip, showTooltip, Decoration, tooltips, gutter, GutterMarker, lineNumberMarkers, lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, crosshairCursor, scrollPastEnd, ViewPlugin },
{ EditorState, EditorSelection, Compartment, Prec, RangeSet, StateEffect, StateField },
langSql,
{ autocompletion, startCompletion, acceptCompletion, closeBrackets, closeBracketsKeymap, snippetCompletion, completionStatus, completionKeymap, insertCompletionText, nextSnippetField },
@@ -3687,6 +3687,7 @@ onMounted(async () => {
trimmedSelectionLayer(),
selectionMatchOccurrences(),
dropCursor(),
props.readOnly ? [] : scrollPastEnd(),
EditorView.dragMovesSelection.of((event) => !event.ctrlKey && !event.metaKey),
EditorState.allowMultipleSelections.of(true),
indentOnInput(),
@@ -0,0 +1,11 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const queryEditorSource = readFileSync(new URL("../../../components/editor/QueryEditor.vue", import.meta.url), "utf8");
describe("QueryEditor bottom scroll space", () => {
it("allows editable documents to scroll past the last line without changing read-only previews", () => {
expect(queryEditorSource).toContain("scrollPastEnd, ViewPlugin");
expect(queryEditorSource).toContain("props.readOnly ? [] : scrollPastEnd()");
});
});