Bug 399291 - Don't include trailing colons when selecting words via double-click
Summary: Don't include trailing colons when selecting words via double-click
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: font (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2018-10-01 19:13 UTC by Nate Graham
Modified: 2023-07-15 10:25 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 18.12.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2018-10-01 19:13:14 UTC
STEPS TO REPRODUCE
1. grep for a string in source code. For example:
$ cd kwin
$ grep -ri "setresizeonly" .
./plugins/kdecorations/aurorae/src/aurorae.cpp:            setResizeOnlyBorders(*m_extendedBorders);

2. Double-click on the path to select it so you can then copy-and-paste it

OBSERVED RESULT
"./plugins/kdecorations/aurorae/src/aurorae.cpp:" is selected.

EXPECTED RESULT
"./plugins/kdecorations/aurorae/src/aurorae.cpp" should be selected (no trailing colon)

ADDITIONAL INFORMATION:
This is a problem because if you quickly type `$EDITOR <paste> <enter>` to open the file, the colon at the end of the path makes it not exist, so your editor creates a new file instead of opening the existing file. You need to remember to do `$EDITOR <paste> <delete> <enter>`, which is slightly annoying.

SOFTWARE VERSIONS
Everything from git master on KDE Neon
Comment 1 Egmont Koblinger 2018-10-01 21:35:27 UTC
You can configure it under the profile's setting -> Mouse tab.

In gnome-terminal, colon is not included in the set by default, for reasons similar to your preference. We keep getting asked to add it, so that URLs can be selected by a double click (although our URL autodetection, just like konsole's, uses a much more fine grained algorithm than a set of word characters, e.g. excludes the trailing dot, so the result would still be far from perfect). Colon is by far the most debated character whether should be included or not by default.
Comment 2 Nate Graham 2018-10-01 21:41:01 UTC
Thanks!

I can see the argument for consistency with GNOME Terminal, but I'd rather not wade into that debate right now.

Regardless of whether or not a colon is added to that list, I'm saying that a colon on the very end, with nothing but whitespace after it, should never be considered part of a URL for autodetection purposes. We don't need to add it to that list to implement the proposal and fix this issue. It may even result in reduced user pressure for adding a colon to the list. :)
Comment 3 Egmont Koblinger 2018-10-01 21:48:07 UTC
Don't get me wrong, I didn't mean to pressure you to sync with gnome-terminal :) Do whatever you prefer. I just added a data point that you might find useful.

BTW I'm not sure why you're talking about URLs, it's a bit misleading. Your use case is just words (it's even irrelevant now that they are local filenames) ending in colons, nothing like file:// or http:// in the game.

> I'm saying that a colon on the very end, with nothing but whitespace after
> it, should never be considered part of a URL for autodetection purposes.

Having a user-configurable set, plus an actual behavior that contains further hacks and doesn't fully respect what the user configured, would in my opinion be pretty confusing. But again, it's KDE's choice, I'm just stating my opinion.
Comment 4 Nate Graham 2018-11-01 04:25:47 UTC
Well anyway, here's a patch: https://phabricator.kde.org/D16578

Let's see what Kurt thinks.
Comment 5 Kurt Hindenburg 2018-11-02 13:51:45 UTC
Git commit 9ce051371dcf98ad14c2dffdf567fe01f0a369e5 by Kurt Hindenburg, on behalf of Nate Graham.
Committed on 02/11/2018 at 13:51.
Pushed by hindenburg into branch 'master'.

Don't consider a colon before whitespace to be part of a word

Summary:
Currently, colons are considered to be part of words for the purpose of
double-click selection. This allows, for example, URLs to be selected
with a double click. This is good.

However, including colons works less well for paths that end with a colon
and whitespace--such as `grep` output. Removing the colon from the list
of word characters isn't a great solutionsince then URLs can no longer be
selected by double-clicking.

This patch resolves that particular issue by always omitting a colon from
double-click selection when it's immediately followed by whitespace.
FIXED-IN: 18.12.0

Test Plan:
`grep -ri charClass .`
Then double-click on one of the paths in the output. The trailing colon
is not included in the selection.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D16578

M  +6    -2    src/TerminalDisplay.cpp

https://commits.kde.org/konsole/9ce051371dcf98ad14c2dffdf567fe01f0a369e5
Comment 6 Oswald Buddenhagen 2023-07-15 10:25:05 UTC
hard-coding the exception is a rather questionable solution.

a fully generic solution would be a configurable regular expression.
however, that might be considered too complex for regular users, and not necessarily very useful to start with.

a less complex solution would be having an additional character class: mid-word characters. these would be considered part of the word only if surrounded by regular word characters. apart from the colon, the period would be included here as well.