Xterm.js: [SelectionManager] Clear selection on input

Created on 11 Jul 2017  路  7Comments  路  Source: xtermjs/xterm.js

It feels strange that the selection remains active once the user continues typing. Is this behaviour explicitly wanted? For comparison, the default behaviour for the OSX terminal is to clear the selection on input.

typbug

Most helpful comment

Yep! Maybe I'll get to it tomorrow, otherwise I'll take care of it in a week when I'm back from holidays 馃殻

All 7 comments

This is as designed but open to improving it. gnome-terminal and terminator on Linux do not clear the selection unless the characters within the selection changed. For example, select something under the prompt and run some command, or select the prompt and type. It would be interesting to see how cmd.exe and powershell.exe behave.

I would agree with @mofux that the selection should disappear when typing starts.

Do we have any use case of keeping it there? If there is no usage scenario, then I think we should consider it a visual distraction.

Do we have any use case of keeping it there?

Accidentally clearing the selection is the only thing I can think of.

The fix is if non-modifier keys are pressed that do not trigger copy/scroll/etc. are pressed then call clearSelection.

I see your point. It's true that we can't guess if the user pressed the key intentionally or not.

I still believe though that we should vanish the selection when the user presses a keystroke that is expected to "send data", as at this point the user changes mental state from reading, selecting and copying text to writing.

Explanation

I think it's safe to assume that a user typing a key is most of the times intentional since:

  • this is what they are expected to do in a terminal
  • we do not have any data about accidental input entry in xterm.js products

Also, an interesting use case is when a program instructs you to run another command. At that time the user is expected to perform the following actions:

  1. Select the command that program A instructed you to run
  2. Copy the command
  3. Paste the command in the terminal
  4. Run the command

Personally, I perform steps 2. and 3., using the keyboard and I would expect:

  1. The selection to stay, after step 2. (despite the keystroke including a modifier key; C in Cmd + C)
  2. The selection to vanish, after step 3.

I think that this makes sense because after starting typing again you are changing mental mode.

@mofux did you want to do a PR for this one?

Yep! Maybe I'll get to it tomorrow, otherwise I'll take care of it in a week when I'm back from holidays 馃殻

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tandatle picture tandatle  路  3Comments

circuitry2 picture circuitry2  路  4Comments

goxr3plus picture goxr3plus  路  3Comments

kolbe picture kolbe  路  3Comments

jerch picture jerch  路  3Comments