feat: add PROMPT2 support for multi-line query continuation#577
Open
buck-openart wants to merge 1 commit into
Open
feat: add PROMPT2 support for multi-line query continuation#577buck-openart wants to merge 1 commit into
buck-openart wants to merge 1 commit into
Conversation
Implements PROMPT2, the continuation prompt shown on lines 2+ of a multi-line statement — matching psql behaviour. Changes: - Move prompt selection into the f() readline reader closure so the prompt is updated before each individual readline call. The previous approach set it once per statement in Run(), but stmt.Next() reads all continuation lines internally before returning, so PROMPT2 was never seen by readline. - Default PROMPT2 to " " (two spaces). Users who prefer aligned whitespace can set PROMPT2 to %w in ~/.usqlrc. - Implement %w: outputs whitespace matching the visual width of the last rendered PROMPT1, stripping ANSI escape sequences. Adds lastPromptWidth to Handler and a visualWidth() helper. - Register PROMPT2 in env/vars.go defaults and env/list.go help output. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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
Implements
PROMPT2, the continuation prompt shown on lines 2+ of a multi-line statement — matching psql behaviour.f()readline reader closure so it fires before each individualreadlinecall. The previous approach set the prompt once per statement inRun(), butstmt.Next()reads all continuation lines internally before returning, soPROMPT2was never reached.PROMPT2is" "(two spaces) — unobtrusive, no visual noise. Users who prefer aligned whitespace can set\set PROMPT2 %win~/.usqlrc.%w: outputs whitespace matching the visual width of the last renderedPROMPT1, stripping ANSI escape sequences. AddslastPromptWidthtoHandlerand avisualWidth()helper.PROMPT2inenv/vars.godefaults andenv/list.go\? variableshelp output.Test plan
\set PROMPT2 %w— continuation lines align with PROMPT1 width\set PROMPT2 ""— no continuation prompt\? variableslists PROMPT2🤖 Generated with Claude Code