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

Add a setting to disable URL detection #10022

Merged
10 commits merged into from
May 17, 2021
Merged

Add a setting to disable URL detection #10022

10 commits merged into from
May 17, 2021

Conversation

PankajBhojwani
Copy link
Contributor

@PankajBhojwani PankajBhojwani commented May 3, 2021

Summary of the Pull Request

Adds a global setting, experimental.detectHyperlinks, that controls whether we automatically detect links and make them clickable. Default is set to true.

PR Checklist

  • Closes Disable "follow link" #9981
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I work here

Validation Steps Performed

When detectHyperlinks is set to false, links do not underline on hover and are not clickable.

@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels May 3, 2021
@PankajBhojwani
Copy link
Contributor Author

PankajBhojwani commented May 3, 2021

Note, we do not update the terminal's behaviour upon hot reload of this setting, changes to it will only apply to future terminal instances. If people feel strongly about this we could change that but I don't think a hot reload for this is necessary.

EDIT: We update the behaviour with regards to this setting on hot reload now

@carlos-zamora
Copy link
Member

Note, we do not update the terminal's behaviour upon hot reload of this setting, changes to it will only apply to future terminal instances. If people feel strongly about this we could change that but I don't think a hot reload for this is necessary.

I hate to say it, but I think this should be hot reloadable :/. Here's a few reasons:

  • scenario:
    • I'm a random user using the terminal. I see that hyperlinks are on and I think "let me turn it off". I go to the settings and turn it off. But when I go back to the terminal, it's still there. So now I file a bug on the repo saying that it doesn't work.
  • consistency:
    • It looks like all of the other interactivity global settings are hot reload-able, so it's a bit confusing for this one not to be.
  • technical reason:
    • We at the very least should update the Settings UI and schema to say "requires restart" to make this clear to the user.
    • Assuming we decide to make this hot reloadable in the future, then we need to do a whole dance with the localization where one key says "requires restart" but the other one doesn't. And we'll need to keep the localization key around forever even though we don't care about the old one anymore. (this one is just a pet peeve, really)

@carlos-zamora
Copy link
Member

Also, what's the deal with #8293? Specifically thinking about this comment with regards to the future of url detection customization.

@zadjii-msft
Copy link
Member

Also, what's the deal with #8293? Specifically thinking about this comment with regards to the future of url detection customization.

That thread is the entire explanation of why we didn't add this in the first place. We couldn't agree on a simple setting name/design in the first place. Since we couldn't come to a consensus, and no one was asking for the setting, we decided to punt the discussion.

I'm tempted to say: let's toss this in as experimental.detectHyperlinks, so that we can yank it in the future, when we have a real design. That way we can ship this now, without having to fully explore whatever we want from pattern detection. If we want to end up keeping it, we can. If we want to fully replace it with profile:detectPatterns or profile:patterns or an extension or whatever in the future, we can yank it then.

@PankajBhojwani
Copy link
Contributor Author

I like the experimental idea, made that change. Also, the link detection behaviour gets updated with hot reloads now.

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor suggestion :)

src/buffer/out/textBuffer.cpp Outdated Show resolved Hide resolved
Comment on lines -439 to +440
_terminal->UpdatePatterns();
auto lock = _terminal->LockForWriting();
_terminal->UpdatePatternsUnderLock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why'd you split this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling UpdatePatterns from UpdateSettings was causing a hang because of the writing lock, and I didn't want to have both an UpdatePatterns and an UpdatePatternsUnderLock. And since this is the only other place we ask Terminal to update the pattern locations, I thought it'd be fine to ask it to grab the lock

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking to note that we discussed a way to clean up the hot reload logic.

Every time there's a settings reload, we can simply always clear pattern recognizers and re-register the link pattern. We can probably also avoid the detection of the existing pattern recognizer.

Clearing the pattern recognizers: we could reset _currentPatternId to 0 again? I dunno if we need it.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 11, 2021
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 12, 2021
@PankajBhojwani
Copy link
Contributor Author

PankajBhojwani commented May 12, 2021

Every time there's a settings reload, we can simply always clear pattern recognizers and re-register the link pattern.

Made the change!

Clearing the pattern recognizers: we could reset _currentPatternId to 0 again? I dunno if we need it.

I like that just for neatness

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more correct to say that this controls detecting URLs. Hyperlinks are the things we're making out of the URLs, right? Should we reword the JSON key and the settings UI checkbox?

@PankajBhojwani
Copy link
Contributor Author

It's more correct to say that this controls detecting URLs. Hyperlinks are the things we're making out of the URLs, right? Should we reword the JSON key and the settings UI checkbox?

Makes sense! Renamed to detectURLs everywhere for consistency

@PankajBhojwani PankajBhojwani added the AutoMerge Marked for automatic merge by the bot when requirements are met label May 17, 2021
@ghost
Copy link

ghost commented May 17, 2021

Hello @PankajBhojwani!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 7a41be5 into main May 17, 2021
@ghost ghost deleted the dev/pabhoj/disable_link branch May 17, 2021 04:20
@ghost
Copy link

ghost commented May 25, 2021

🎉Windows Terminal Preview v1.9.1445.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants