Skip to content

feat(editor): tab stops and fields in saved query snippets - #3741

Merged
datlechin merged 3 commits into
mainfrom
feat/3612-snippet-tab-stops
Oct 21, 2026
Merged

datlechin merged 3 commits into
mainfrom
feat/3612-snippet-tab-stops

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • Saved query SQL takes tab stops: ${1:default}, ${1}, ${1|ASC,DESC|} and ${0}. The same number twice is one field, mirrored as you type.
  • After keyword expansion, Tab and Shift+Tab move between fields with the field's text selected. Escape, or a selection outside the inserted SQL, ends the session.
  • A choice field opens a menu at the field.
  • ;; still works and means ${0}. A bare $1, $$ or $tag$ stays literal. A field left open leaves the whole query as written.
  • Placeholders in saved queries imported from Sequel Ace now expand as fields.
  • A completion accepted inside a mirrored field goes into every copy.
  • Edits made by the typing filters (auto-pairing) are tracked, so later fields stay in place.
  • An unfilled outline emphasis no longer draws a black copy of its text over the syntax colors.
  • The saved query dialog footer names fields as well as ;;.

Not in this PR

  • Starter snippets per dialect: needs a decision on where they live (seeded saved queries vs a built-in catalog), whether they sync, and the editing UI.
  • Driver statement completions as snippets (HanaMetadata.swift:43): a registry plugin that writes ${1:SCHEMA} would insert it literally on hosts without this engine, so it needs a host version gate first.
  • Insert in Editor, drag and Open Quickly still insert the raw SQL (MainContentCoordinator+Favorites.swift:15 appends the text to the tab). ;; never worked there either.
  • iOS keeps ;; only (SQLCompletionInsertion.resolve).
  • Mirrors follow typing through the editor's multiple selections. Two empty copies at the same spot (${1}${1}, or adjacent copies emptied together) collapse into one caret, so typing fills one copy.

Test plan

  • SQLSnippetTests (TableProAutocompleteTests): fields, mirrors, choices, nesting, escapes, $1/$$/$tag$ literal, ;; as the final stop, the nesting and expansion limits.
  • SnippetSessionTests, SnippetEditingTests (TableProEditorKitTests): Tab visits three fields in order then the end, Shift-Tab, typing into a mirror, adjacent copies, a nested field's edge, completion into mirrors and its undo, a filter edit, Escape, a click outside, choices, undo of the expansion, document replace.
  • EmphasisManagerTests.anUnfilledOutlineDrawsNoCopyOfItsText.
  • QueryCompletionAdapterLifecycleTests: accepting a saved query with fields selects the first field and keeps $1; ;; alone places the caret as before.

Fixes #3612

@datlechin
datlechin merged commit 1c6c02c into main Oct 21, 2026
8 checks passed
@datlechin
datlechin deleted the feat/3612-snippet-tab-stops branch October 21, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snippets with tab stops and placeholders in the SQL editor

1 participant