feat(editor): support ;; cursor marker in favorite keyword expansion#1803
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1795.
SQL Favorites with a keyword already expand to the full saved query from the autocomplete popup. This adds the missing piece from #1795: a way to say where the cursor lands after expansion.
;;anywhere in a favorite's query. On expansion the marker is stripped and the cursor is placed at its position. Without a marker the cursor stays at the end of the inserted SQL, as before.;;counts as a marker; later occurrences stay literal..sqlfiles with@keywordfrontmatter, since both flow through the same completion path.Research note:
;;is not a TablePlus convention. TablePlus has no cursor placement in its keyword bindings (requested there since 2018, never built). The marker is TablePro's own syntax, proposed by the issue author.Implementation
SQLSnippetMarkerfinds and strips the first;;, returning the caret offset in UTF-16 units (NSString-based, per the repo perf rules, so multibyte text before the marker resolves correctly).SQLCompletionInsertion.resolve(for:)owns the full accept-time decision: the favorite marker rule, the existing function()rule, and the end-of-text default. Marker handling is gated on the.favoritekind, so other completions containing a literal;;are never altered.SQLCompletionAdapter.completionWindowApplyCompletionshrinks to resolve, onereplaceCharacterscall, andsetCursorPositions. One insert mutation means one Cmd+Z restores the typed keyword. The IMEhasMarkedText()guard is unchanged.FavoriteEditDialogshows a caption under the Query field explaining the marker.Tests
SQLSnippetMarkerTests: marker at start/middle/end, first-occurrence-only, multibyte/emoji offset correctness, and the issue's exact template.SQLCompletionInsertionTests: favorite with and without marker, mid-query marker, function paren rule, markerless favorite ending in(), non-favorite item containing a literal;;.SQLCompletionProviderTests: the favorite factory keeps the raw marker ininsertText, pinning that stripping happens at accept time only.There is no direct test for
completionWindowApplyCompletionitself: all branching moved into the pure helpers, and the remaining AppKit glue matches the accepted pattern inperformFormatSQL. ATextViewControllertest harness was evaluated and rejected because the CodeEdit package does not export its test utilities.Out of scope
SyncRecordType.favoriteand.favoriteFolderexist but are unwired inSyncCoordinator, so favorites do not sync today. Pre-existing gap, should get its own issue.;;in whole-tab insertion paths (Insert Favorite, run in new tab, drag and drop, Quick Switcher). Those set tab state before an editor exists and need a pending-cursor mechanism like the SQL editor should receive focus when creating a new tab #1765 focus fix.