Pasting a multiline block of text does not autoMarkPrompts #20354

Closed
opened 2026-01-31 07:11:14 +00:00 by claunia · 6 comments
Owner

Originally created by @zadjii-msft on GitHub (Aug 9, 2023).

Originally assigned to: @zadjii-msft on GitHub.

  1. Turn on "experimental.autoMarkPrompts": true, and "experimental.rightClickContextMenu": true,
  2. turn on shell integration too. Just in general always, it's goodness.
  3. Copy the following
command-one
dir
command-two
command-three
  1. Paste it. Accept the warning.
  2. Try to right-click "select output" or command.
  3. Observe that it no worky.

Surely, when we paste text, we're not going through the same path in Terminal.cpp that marks enter

Originally created by @zadjii-msft on GitHub (Aug 9, 2023). Originally assigned to: @zadjii-msft on GitHub. 1. Turn on `"experimental.autoMarkPrompts": true,` and `"experimental.rightClickContextMenu": true,` 2. turn on shell integration too. Just in general always, it's goodness. 3. Copy the following ``` command-one dir command-two command-three ``` 4. Paste it. Accept the warning. 5. Try to right-click "select output" or command. 6. Observe that it no worky. Surely, when we paste text, we're not going through the same path in `Terminal.cpp` that marks <kbd>enter</kbd>
Author
Owner

@zadjii-msft commented on GitHub (Aug 9, 2023):

Note: don't do this for

  • the alt buffer
  • bracketed paste
@zadjii-msft commented on GitHub (Aug 9, 2023): Note: don't do this for * the alt buffer * bracketed paste
Author
Owner

@zadjii-msft commented on GitHub (May 10, 2024):

Similarly, this doesn't work if you sendInput(foo\rbar\nbaz). None of them seem to work to mark.

I'm guessing it's because sendInput comes in through the paste handler. Might be able to fix

@zadjii-msft commented on GitHub (May 10, 2024): Similarly, this doesn't work if you `sendInput(foo\rbar\nbaz)`. None of them seem to work to mark. I'm guessing it's because sendInput comes in through the paste handler. Might be able to fix
Author
Owner

@DHowett commented on GitHub (May 10, 2024):

I am somewhat anti-this. Most multi-line pastes are into things that aren't shells probably...

@DHowett commented on GitHub (May 10, 2024): I am somewhat anti-this. Most multi-line pastes are into _things that aren't shells_ probably...
Author
Owner

@zadjii-msft commented on GitHub (May 10, 2024):

The alt buffer doesn't have marks at all, so there's that to mitigate some concerns.

FWIW I even tried doing sendInput with \u001b[13;28;13;1;32;1_\u001b[13;28;13;0;32;1_ (enter) and even that didn't mark the commands ended.

(I may be able to fake this better with powershell)

@zadjii-msft commented on GitHub (May 10, 2024): The alt buffer doesn't have marks at all, so there's that to mitigate some concerns. FWIW I even tried doing `sendInput` with `\u001b[13;28;13;1;32;1_\u001b[13;28;13;0;32;1_` (enter) and even that didn't mark the commands ended. (I may be able to fake this better with powershell)
Author
Owner

@zadjii-msft commented on GitHub (May 13, 2024):

Okay, well, this actually will just never work (for probably obvious reasons). I'm focusing narrowly on the sendInput scenario here, but it's equally obvious for paste.

When we call ControlCore::SendInput, we write the text directly to the connection. We could split that on each \r, and then try to automark on each of those newlines, BUT: we don't know when the output of each of those will be. We'd write a block, mark the line, write a block, mark, etc, probably multiple times before we got the first bit back out of the first command. When we get that block, nothing will actually get emitted before we write the whole block.

uhg.

Goddard, options:

  • COOKED_READ emits a 133;C when it processes an enter
    • dangerous, certainly too dangerous for Build)
  • add some sort of commands param to sendInput, and that will wait to the next prompt between sending elements in the commands array
    • deeply underspec'd
  • definitely just cut this from the demo? Or at least blow past the fact that the command also gets selected
  • add a sleep action that literally just Sleeps for that timeout, so that I can then multipleActions([sendInput, sleep, ]) ah fuck see that still doesn't work. Still doesn't mark the command
  • Maybe see if I can bodge PWSH into supporting 133;C without automarking
@zadjii-msft commented on GitHub (May 13, 2024): Okay, well, this actually will just never work (for probably obvious reasons). I'm focusing narrowly on the sendInput scenario here, but it's equally obvious for paste. When we call `ControlCore::SendInput`, we write the text directly to the connection. We _could_ split that on each `\r`, and then try to automark on each of those newlines, BUT: we don't know when the output of each of those will be. We'd write a block, mark the line, write a block, mark, etc, probably multiple times before we got the first bit back out of the first command. When we get that block, nothing will actually get emitted before we write the whole block. uhg. Goddard, options: * COOKED_READ emits a 133;C when it processes an enter * dangerous, certainly too dangerous for Build) * add some sort of `commands` param to sendInput, and that will wait to the next prompt between sending elements in the commands array * deeply underspec'd * definitely just cut this from the demo? Or at least blow past the fact that the command also gets selected * add a `sleep` action that literally just `Sleep`s for that timeout, so that I can then `multipleActions([sendInput, sleep, ])` ah fuck see that still doesn't work. Still doesn't mark the command * Maybe see if I can bodge PWSH into supporting 133;C without automarking
Author
Owner

@zadjii-msft commented on GitHub (May 14, 2024):

You know what, in light of how painful some of the proposed fixes are, and how specifically automarkPrompts==="mark when you press enter", then I'm gonna close this out as "by design". Kinda unexpected, and I could be convinced the other way, but only if there was a good solution proposed.

@zadjii-msft commented on GitHub (May 14, 2024): You know what, in light of how painful some of the proposed fixes are, and how specifically `automarkPrompts`==="mark when you press enter", then I'm gonna close this out as "by design". Kinda unexpected, and I could be convinced the other way, but only if there was a good solution proposed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20354