Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join lines that fills the width when selecting urls #1475

Merged
1 commit merged into from
Jun 9, 2020

Conversation

trygveaa
Copy link
Contributor

@trygveaa trygveaa commented Feb 28, 2020

Some terminal applications, like mutt and weechat, prints a newline at
the end of each line even if text is wrapped. This causes urls which are
wrapped to not be selectable in full.

By ignoring newlines when the text fills the entire width of the screen,
those urls can be selected. Many other terminal emulators do this as
well.

A drawback of this is that if a url happens to fill the width of the
screen, the url selection will include the first word of the next line,
but this doesn't happen that often so I think it's an okay tradeoff.

Fixes #313

@trygveaa trygveaa force-pushed the join-full-lines-for-url-selection branch from 55a664d to 1ffd8ca Compare February 28, 2020 21:58
@trygveaa
Copy link
Contributor Author

A drawback of this is that if a url happens to fill the width of the
screen, the url selection will include the first word of the next line,
but this doesn't happen that often so I think it's an okay tradeoff.

What do you think of this? Alternatively I can make it configurable.

Some terminal applications, like mutt and weechat, prints a newline at
the end of each line even if text is wrapped. This causes urls which are
wrapped to not be selectable in full.

By ignoring newlines when the text fills the entire width of the screen,
those urls can be selected. Many other terminal emulators do this as
well.

A drawback of this is that if a url happens to fill the width of the
screen, the url selection will include the first word of the next line,
but this doesn't happen that often so I think it's an okay tradeoff.

Fixes termux#313
@trygveaa trygveaa force-pushed the join-full-lines-for-url-selection branch from 1ffd8ca to 7d748d4 Compare February 28, 2020 22:21
@ghost ghost requested a review from fornwall June 7, 2020 01:09
@ghost ghost merged commit 5f71e3e into termux:master Jun 9, 2020
@ghost
Copy link

ghost commented Jun 9, 2020

A drawback of this is that if a url happens to fill the width of the
screen, the url selection will include the first word of the next line,
but this doesn't happen that often so I think it's an okay tradeoff.

I wasn't able to reproduce that. Tested with file full of long URLs opened with nano --softwrap.

@trygveaa
Copy link
Contributor Author

trygveaa commented Jun 9, 2020

It only happens when the url exactly fills the width of the terminal. You can reproduce it with this command:

printf 'http://%*s.com/\nshould-not-be-part-of-url\n' $(($COLUMNS-12)) | tr ' ' a

It will print one line with http://aaa...aaa.com/ and the next with should-not-be-part-of-url. The terminal has no way of knowing if the second line should be part of the url or not, which means that in cases that it shouldn't be a part of the url, it will be wrong.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Links on multiple lines cannot be copied
1 participant