Skip to content

Address misplaced cursor#159325

Merged
alexdima merged 4 commits intomicrosoft:mainfrom
jacekkopecky:cursor-fixes
Oct 24, 2022
Merged

Address misplaced cursor#159325
alexdima merged 4 commits intomicrosoft:mainfrom
jacekkopecky:cursor-fixes

Conversation

@jacekkopecky
Copy link
Contributor

@jacekkopecky jacekkopecky commented Aug 26, 2022

Fixes #156788

It looks like the "centering" is the main culprit causing my issue.

Test this by the following steps:

  1. configure a wide-ish line cursor (so the letters underneath show up inside the cursor)
  2. observe how with this PR the letter is no longer shifted by a pixel inside the cursor when not in text column 0

This is most visible on high-DPI screens where a pixel translates to several real pixels.

If we want to keep the "centering", or if we actually want to truly center the line cursor by half its width, we'd need to add left padding to the cursor element so that the shift left is balanced by the content shifting right. It would mean adding left padding (or all paddings) to fastDomNode. Let me know if you'd like that.

@jacekkopecky
Copy link
Contributor Author

@alexdima I've realized that my commit message might be seen as criticising your earlier commit, sorry if it came across that way. I hadn't realized that this tweak was part of a fix for an earlier issue.

It doesn't seem that issue #55640 recurs with my reversal of that "centering"; but if you'd prefer, I can look at the approach outlined above that can shift the cursor without moving the text inside it.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

I see how this is super annoying. Maybe we can avoid doing the -1 when having a wide cursor. But simply removing the -1 ends up impacting negatively the cursor placement on macOS with default settings:

Before the proposed change:

image

With the proposed change:

image

@jacekkopecky
Copy link
Contributor Author

I understand; I've updated the PR so the cursor does shift by 1px but it adds left padding so the text is where it's supposed to be. What do you think @alexdima ?

I've spotted something else: it looks like the last line of real code which returns width: 2 may want to return the actual width of the cursor. But it may be harmless.

@alexdima
Copy link
Member

I've updated the PR so the cursor does shift by 1px but it adds left padding so the text is where it's supposed to be.

The change looks alright in principle, but I think the extra padding is making the default cursor "fatter". Here it is running from source on macOS with default settings:

Before the proposed change With the proposed change
image image

I've spotted something else: it looks like the last line of real code which returns width: 2 may want to return the actual width of the cursor. But it may be harmless.

That's a good catch! I've created #164484 to track fixing that.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

Thank you!

@alexdima alexdima enabled auto-merge (squash) October 24, 2022 18:51
@alexdima alexdima added this to the October 2022 milestone Oct 24, 2022
@alexdima alexdima merged commit 23a3c6e into microsoft:main Oct 24, 2022
formigoni pushed a commit to formigoni/vscode that referenced this pull request Oct 27, 2022
* Remove ill-advised tweak

* Shift cursor back by 1px but leave text in place

* Always use `box-sizing: border-box`

Co-authored-by: Alexandru Dima <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 10, 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.

Line cursor shifts underlying text by a few pixels

3 participants