Shell integration: Fix PS2 prompt reporting #212491
Open
+1
−1
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.
Currently shellIntegration-bash attempts to handle raw ESCs within the
PS2
continuation prompt by converting them to backslash-escapes... but then it feeds those backslash-escapes toprintf
which immediately converts them back.And in most cases, just like PS1, the PS2 will have
\e
backslash-escaped form anyway – which still leads to the same problem of printf translating them back to raw ESC.For example, if PS2 is set to:
(with Bash strings keeping the
\[
and\e
as literal text), then the printf results in the output:With this change, it should result in the expected:
(Yes, I noticed __vsc_report_prompt() just a few lines below which does everything differently with PS1 – I'm pretty sure the same code should be handling both prompts identically, but I'm not sufficiently familiar with the code to attempt unifying them just yet.)