Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip FreshLine by semantic integration in ble.sh #5072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akinomyoga
Copy link

@akinomyoga akinomyoga commented Feb 25, 2024

A problem was originally reported in akinomyoga/ble.sh#413. ble.sh (a line editor for Bash) keeps track of the cursor position in the terminal display (including the horizontal position relative to the bottom of the terminal) based on the terminal control sequences that it sends.

However, with WezTerm's semantic integration, WezTerm may insert a newline in precmd (FreshLine), which breaks the cursor position tracking of ble.sh. The needed cursor position adjustment at the end of the command execution is already performed by ble.sh, so WezTerm does not need to adjust it. In this patch, we skip the request for FreshLine in ble.sh.

But I'm not sure if this is the correct fix. The original sequence OSC A seems to perform FreshLine and StartPrompt. To only perform StartPrompt, one seems to be able to use the sequence OSC P ... BEL. Although OSC P seems to receive a parameter k=?, it doesn't seem to be used in the codebase, so I just omitted the parameter k. Could you take a look at this?

Note: As an alternative option, we can specify the ble.sh option bleopt prompt_command_changes_layout=1 to notify that precmd/PROMPT_COMMAND can change the cursor position (in particular horizontal position), but this adds unneeded flickering of the rendered contents. Because we can just suppress FreshLine this time, I didn't use this approach.

ble.sh keeps track of the cursor position in the terminal
display---including the horizontal position relative to the bottom of
the terminal---based on the terminal control sequences that it sends.
However, with WezTerm's shell integration, WezTerm inserts the newline
(FreshLine) in PROMPT_COMMAND, which breaks the cursor position
tracking of ble.sh.  The needed cursor position adjustment at the end
of the command execution is already performed by ble.sh, so WezTerm
does not need to adjust it.  In this patch, we skip the request for
FreshLine.
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.

None yet

1 participant