microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
94.2k stars 8.16k forks source link

Feature Request: Smart Double-click Selection (regeces?) #3196

Open stephanosio opened 4 years ago

stephanosio commented 4 years ago

Description of the new feature/enhancement

The current implementation of mouse double-click in terminal window only selects a word, and triple click selects the entire line.

It is often necessary to select an entire path or other forms of multi-word string (e.g. decimal number, percent value, abbreviated size, email address, ...) when using terminal and it would be nice to have an automatic detection and selection of such multi-word strings.

For example, when using git, typing git status returns the relative paths of the changed files: image

If I wanted to copy the path of a specific file (e.g. to diff or open), with the current implementation, I would have to manually drag and select the path of the file. With the requested feature, however, I would only need to double click anywhere on the path of the file and this speeds things up by a lot.

GNOME Terminal already implements the behaviour described here, and it is an extremely useful feature that makes everyday tasks so much simpler and speeds things up significantly.

Proposed technical implementation details (optional)

Define a set of regex rules for detecting and selecting commonly used multi-word strings. Maybe these rules can be customisable in the settings file.

DHowett-MSFT commented 4 years ago

Would you be helped by removing ./\ from your word delimiters? You can override the default ones by adding it to your own settings file, and perhaps help path selection at the same time.

stephanosio commented 4 years ago

@DHowett-MSFT Didn't realise delimiter configuration was added. For the most part, that seems to do the trick.

I was really thinking more of regex though, because it can be a good starting point for implementing more advanced features like type-specific smart highlighting and hyperlinking of terminal text, not just smart selection.

wmakley commented 4 years ago

I would be happy if it just selected the entire phrase using whitespace delimiter on a triple click. The whole line is rarely useful.

jakebrinkmann commented 4 years ago

@DHowett-MSFT or @stephanosio can you provide the example entry for profiles.json that you settled on? This is what I have:

    "wordDelimiters": "\\ ()':,;<>!@#$%^&*|+=[]{}?│",

note: \\ seems needed for JSON parsing

e-Dark commented 4 years ago

In additional to subject - it would be nice to have some alternative word delimiters. So default word delimiter for double click. And 3 alternative word delimiters for Alt, Ctrl and Shift + double click.

torselden commented 4 years ago

I'm running version 0.9.433.0 and I have basically exactly the same use case and feature request as OP. I've tried adding and changing the "wordDelimiters" setting as suggested in this thread with no effect what so ever.

Can anyone confirm that this method actually works, or is it related to which shell you are running? This is my config: { "guid": "{00000000-0000-0000-ba54-000000000002}", "tabTitle": "Git Bash", "copyOnSelect": true, "acrylicOpacity" : 0.75, "closeOnExit" : true, "colorScheme" : "Campbell", "commandline" : "\"%PROGRAMFILES%\\git\\bin\\bash.exe\" --login -i -l", "cursorColor" : "#FFFFFF", "cursorShape" : "bar", "fontFace" : "Consolas", "fontSize" : 12, "historySize" : 9001, "name" : "Git Bash", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "startingDirectory" : "C:\\git", "useAcrylic" : false, "wordDelimiters": ":", "icon" : "%PROGRAMFILES%\\git\\mingw64\\share\\git\\git-for-windows.ico" }

u7pro commented 4 years ago

hi @torselden,

You can find here the settings schema: https://aka.ms/terminal-profiles-schema

wordDelimiters is a global property, it should be on top of the settings : image

torselden commented 4 years ago

Thank you so much! This worked perfectly!

u7pro commented 4 years ago

Thank you so much! This worked perfectly!

You're welcome, I'm glad it helps..

mimi89999 commented 4 years ago

Why are / and \ in the path delimiter list? I had the same issue and found that this can be configured only after seeing this issue.

zadjii-msft commented 4 years ago

@mimi89999 because some people use the Terminal with cmd and powershell, which use \ as the path separator. Other people use the Terminal for WSL, which uses /. Some people use the Terminal for both and want to treat both characters as a path separator.

mimi89999 commented 4 years ago

In terminals on GNU/Linux \ is also not treated as a separator, so removing it from the list wouldn't feel strange on WSL. I don't know if in cmd and powershell / is normally a separator.

Some people use the Terminal for both and want to treat both characters as a path separator.

Normally (in terminal apps on GNU/Linux) the path separator is ignored when selecting. In gnome-terminal when I select a string that contains / or \ it is treated as one 'word' and the entire path or string with escape characters gets selected.

zadjii-msft commented 4 years ago

Thanks for sharing! This exact reason is why we provide the wordDelimiters setting, so users can configure it however they like 😄

randomascii commented 4 years ago

Thanks for sharing! This exact reason is why we provide the wordDelimiters setting, so users can configure it however they like 😄

It is, indeed, good that the wordDelimiters setting is provided. However the earlier question of why / and \ are delimiters by default was never really answered. Defaults matter. There seem to be a lot of people who feel that / and \ should not be delimiters (cmd and terminals on GNU/Linux don't treat it as such) so probably the defaults should be changed.

If everybody has to dramatically configure the new terminal to make it usable then that harms interoperability and significantly raises the learning curve. I am repeatedly surprised at how many defaults I have had to change to get the terminal to work well.

Uxorious commented 4 years ago

Same issue here ... except I think a simple improvement could be to allow wordDelimiters in the profiles section (Which I see is already handled in #3078). That way we could remove / from the Linux profile and :\ from the PowerShell/Command profiles.

drewwells commented 3 years ago

Can anybody provide sensible settings for wordDelimiter? Indeed, '/' is a terrible idea. How would you select a full URL? iTerm has a very advanced set of configurable regexs that also implement priority for say selecting a URL over plain text. https://iterm2.com/documentation-smart-selection.html#:~:text=When%20Smart%20Selection%20is%20activated,pool%20of%20%22selection%20candidates%22.

zadjii-msft commented 3 years ago

I personally use:

"wordDelimiters" : " ()\"':,;<>~!@#$%^&*|+=[]{}~?\u2502",
randomascii commented 3 years ago

I kept deleting delimiters that annoyed me until I ended up with this set:

"wordDelimiters": " ()\"';<>~!@#$%^&*|=[]{}~?\u2502"

I haven't changed it for a month or two so I guess I'm happy with it. I can double-click paths and the URLs I encounter and most of the other things that I routinely encounter. Of course this depends greatly on ones workflow so I'm not sure I can justify my modifications in general.

phealy commented 3 years ago

I would love to see this implemented like iTerm2 does it - on a quadruple click.

This has a few advantages from my perspective:

  1. Default behavior of double/triple click isn't changed.
  2. Easy to access - just one more click.
  3. Enabling or disabling it doesn't change much in the way of expected behaviors - the only thing changed is that there's one more click to reach "clear your selection" if you keep clicking on the same spot.
vizzard commented 3 years ago

maintainer edit: collapsing this as off-topic, because this was originally tracked in #4009, and fixed in v1.20.10293.0

Please consider adding a feature to select a multi line string with double click. I often work with tokens or something base64 encoded. I usually was able to double click multi line string to select all of the lines using other terminals. With Windows Terminal, double click selects one line only. I have to drag the selection from the beginning to end with special care not to select leading or trailing spaces. WSLtty example of expected behavior:

S9fnmuw60O

zoukyle commented 3 years ago

Looking for the multi line double click selection too. Gnome terminal has this.

mlukac commented 3 years ago

Yes, this would be nice!

darrylmelander commented 2 years ago

I'd like a way to decide on the fly whether I'm selecting a word (just part of a path), a full path, or a full line. Custom word delimiters let you pick whether double clicking selects a word or a path, but it doesn't give you an easy way to do both without dragging. Could we maybe add shift double click to select using alternate word delimiters?

gobbedy commented 2 years ago

+1 for multi-line double click selection. I googled this and landed here

zadjii-msft commented 2 years ago

@gobbedy If you'd like to "+1" this feature, the best way to do that is by hitting the 👍 button on this issue

image

That way, you avoid unnecessarily pinging everyone following this thread. Thanks!