Fix terminal tab prompt input breaking when backticks are included#272425
Conversation
479b5dd to
6a9c04d
Compare
Abrifq
left a comment
There was a problem hiding this comment.
OoT/pet peeve:
Prompt input sometimes gets an extra space appended.
Need to check _doSync() for what could cause it:
6a9c04d to
7b0877c
Compare
|
Hi, I have tested my PR within codespaces' VNC, it does work now. I had to enable vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.ts Lines 46 to 49 in 5e797a9
There might be a desync causing this, needs more investigation. As I started that comment, it is out of topic. |
ab88aa6 to
5e797a9
Compare
backtick wrapping with <code>wrapping</code>
5e797a9 to
fc5842d
Compare
|
Thanks for the PR. Can you pls provide a screenshot of this working for you in testing? |
fc5842d to
3a92ee4
Compare
This comment was marked as outdated.
This comment was marked as outdated.
3a92ee4 to
4e717e0
Compare
Update:Prefixing backslashes to backticks makes them show up again.
I'll also check if just applying db999f4 onto main works. |
644016f to
3ccfea3
Compare
I have tested (https://regexr.com/8hu9f) and it should be good for now. Testing with this input: echo `date`; echo </code>[escaped link?](https://youtu.be/dQw4w9WgXcQ "asdasdasd")Main Branch (124710c)
My patch (3ccfea3)
|
It does not. Until someone confirms that markdown rendering inside If I didn't misread the code when I first opened this issue/PR, the changes I made should run once per keystroke, so it should -hopefully- have only negligible performance impacts. |
3ccfea3 to
9030ea6
Compare
9030ea6 to
d30c10e
Compare
|
I guess feature release from Github Universe could have created some urgent backlog but is there anything blocking this PR from being reviewed? Edit: Well, the Monthly Endgame has started. Oh well. |
|
Hello @meganrogge, while waiting for this PR to get reviewed, should I update the base branch to test against newer base or should I leave as is? I'm asking this in general, it's not mentioned in contributing guide. |
|
|
||
| const shellProcessString = getShellProcessTooltip(instance, !!showDetailed); | ||
| const content = new MarkdownString(instance.title + shellProcessString + statusString, { supportThemeIcons: true }); | ||
| const content = new MarkdownString(instance.title + shellProcessString + statusString, { supportThemeIcons: true, supportHtml: true }); |
There was a problem hiding this comment.
Why do we need to supportHtml here to fix this?
There was a problem hiding this comment.
Current markdown parsing doesn't allow for escaping backticks via a backslash, and to workaround that I have changed the backtick wrapping with <code> wrapping.
Code wrapping does not work unless supportHtml is enabled, though. Which is why I enabled it.
| const escapedPromptInput = combinedString | ||
| .replaceAll('<', '<').replaceAll('>', '>') //Prevent escaping from wrapping | ||
| .replaceAll(/\((.+?)(\|?(?: (?:.+?)?)?)\)/g, '(<$1>$2)') //Escape links as clickable links | ||
| .replaceAll(/([\[\]\(\)\-\*\!\#\`])/g, '\\$1'); //Comment most of the markdown elements to not render them inside | ||
| detailedAdditions.push(`Prompt input: <code>\n${escapedPromptInput}\n</code>`); |
There was a problem hiding this comment.
isn't this just as simple as escaping inner backticks like this?
combinedString.replaceAll('`', '\\`')There was a problem hiding this comment.
I have tried it and it didn't work that time
( #272425 (comment) )
But I will update the branch & try again and report here.
There was a problem hiding this comment.
The current proposal seems far too complex for what this actually does imo, all it's doing is making debug information show a little nicer. Does this helper do the job?
vscode/src/vs/base/common/htmlContent.ts
Lines 153 to 156 in 1d4fe40
There was a problem hiding this comment.
Does this helper do the job?
vscode/src/vs/base/common/htmlContent.ts
Lines 153 to 156 in 1d4fe40
Yeah, it should replace line 115. Thanks!
The current proposal seems far too complex for what this actually does imo, all it's doing is making debug information show a little nicer.
I need to check if lines 112, 113 & 116 themselves are good enough to ONLY fix the wrapping, but I faintly recall they were not.
As for line 114, I have stated in meganrogge's review that it's basically optional and can be removed.
I'll see what I can do within my lunch break, and thanks for the helper.
backtick wrapping with <code>wrapping</code>
Tyriar
left a comment
There was a problem hiding this comment.
@meganrogge simplified it, basically handling the edge case where backtick is included specially instead of adding HTML support/complicated regexes. Could you check it out?
|
@Abrifq let me know if you're able to break this one, but I think it's solid |
Sorry, I just became available to check, I will update but this feels weird on UX.
|
|
There is an even simpler version, I will make a new PR on top of this one. @@ -109,15 +109,8 @@ export function refreshShellIntegrationInfoStatus(instance: ITerminalInstance) {
}
const combinedString = instance.capabilities.get(TerminalCapability.CommandDetection)?.promptInputModel.getCombinedString();
if (combinedString !== undefined) {
- if (combinedString.includes('`')) {
- detailedAdditions.push('Prompt input:' + [
- '```',
- combinedString, // No new lines so no need to escape ```
- '```',
- ].map(e => `\n ${e}`).join(''));
- } else {
- detailedAdditions.push(`Prompt input: \`${combinedString.replaceAll('`', '`')}\``);
- }
+ // Wrap with triple backticks so that single backticks can show up (command substitution in bash uses backticks, for example)
+ detailedAdditions.push(`Prompt input: \`\`\`${combinedString}\`\`\``);
}
const detailedAdditionsString = detailedAdditions.length > 0
? '\n\n' + detailedAdditions.map(e => `- ${e}`).join('\n') |
Well, that's the simplest, the cleaner solution would be either adding some if not all css properties of |
|
@Abrifq we definitely don't want to support HTML there. I also don't want to get into trying to change the markdown rendering. Again this is just debug info that's hidden by default, handling all edge cases perfectly isn't too important. |
…t-input-visual-fix Cleanup #272425





Closes #272416.
I have tested the changes manually via codespaces.