Skip to content

Enable user-select for monaco editor on macOS#156755

Merged
hediet merged 2 commits into
microsoft:mainfrom
pingren:fix/macos-lookup
Oct 3, 2022
Merged

Enable user-select for monaco editor on macOS#156755
hediet merged 2 commits into
microsoft:mainfrom
pingren:fix/macos-lookup

Conversation

@pingren

@pingren pingren commented Jul 31, 2022

Copy link
Copy Markdown
Contributor

Fixes #85632

macOS lookup won't work for text setting or inherited user-select: none stylesheet.

The related code was changed many years ago:

I tested #44517 is not reoccurring.

2022-07-31 22 49 33

Comment on lines +29 to +37
/* Use user-select: text for lookup feature on macOS */
/* https://github.com/microsoft/vscode/issues/85632 */
.monaco-editor.mac .lines-content:hover,
.monaco-editor.mac .view-line:hover,
.monaco-editor.mac .view-lines:hover {
user-select: text;
-webkit-user-select: text;
-ms-user-select: text;
}

@ushuz ushuz Jul 31, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I can confirm this working, by modifying local CSS through builtin dev tools.

But not without a catch, when editor.renderWhitespace is set to all, the whitespace indicators between words (<span class="mtkw">·‌&zwnj;</span>) may interfere with OS's tokenization, causing lookup to pick up the wrong word.

It may be outside the scope of this PR, though.

Screen.Recording.2022-07-31.at.13.31.42.mov

@pingren pingren Aug 1, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I am afraid that we can't do much about OS tokenization.

UPDATE
I found a fix for this. Since it is out of scope of the original issue. I will make another PR after this one get merged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you share the change here, just curious what it would be?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MacOS won't treat &zwnj;(0x200C) as word separators. So we could add normal whitespace characters similar to #150349

@lramos15 lramos15 assigned alexdima and unassigned lramos15 Aug 1, 2022
@stepelu

stepelu commented Aug 28, 2022

Copy link
Copy Markdown

Any hope for this to be looked at and closed soon? :)

@bpasero bpasero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am curious though, if #44517 does not reproduce, why would we do this change only for :hover? It seems very hard for me to reason about a CSS change for selection only on hover, because isn't that exactly when a selection occurs? When hovering with the mouse over?

@pingren

pingren commented Sep 7, 2022

Copy link
Copy Markdown
Contributor Author

@bpasero

Elements in the editor will inherit default stylesheet user-select: none according to

  1. Global CSS
  2. A function set editor class name: https://github.com/microsoft/vscode/blob/main/src/vs/editor/browser/config/editorConfiguration.ts#L207

user-select: none broke macOS lookup functionality. Since these code were in the codebase for many years. I limit the scope to :hover to make the fix scope as small as possible (macOS users have to hover the text to lookup) and hope it won't introduce any regressions.

@hediet

hediet commented Sep 29, 2022

Copy link
Copy Markdown
Member

hope it won't introduce any regressions.

That's a fear I have.

Why is user-select: none default?

We can merge this early next iteration and see if there are any regressions in insiders for mac-users.
@bpasero what are your thoughts?

@hediet hediet added this to the October 2022 milestone Sep 29, 2022
@bpasero

bpasero commented Sep 29, 2022

Copy link
Copy Markdown
Contributor

Yes I like early milestone merge to scan for regressions.

@hediet
hediet merged commit d89a82c into microsoft:main Oct 3, 2022
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Look up & data detectors" feature not working on Mac OS with VS code

9 participants