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

Improve drawSelection to take into account textIndent #21

Closed
wants to merge 1 commit into from

Conversation

lishid
Copy link
Contributor

@lishid lishid commented Dec 14, 2021

FIX: Properly draw selections when text-indent is used for soft wrapping.

@marijnh
Copy link
Member

marijnh commented Dec 14, 2021

Since text-indent will only affect the first line of an element, won't this go wrong when the line is actually wrapped, allowing the continued lines to stick out of the drawn selection block?

@lishid
Copy link
Contributor Author

lishid commented Dec 14, 2021

Yes, but I think it looks more correct when the selection block aligns with the left side where the first line starts:

Before patch:
image

After patch:
image

@lishid
Copy link
Contributor Author

lishid commented Dec 14, 2021

Ah I see what you mean - if the editor is using positive text indent (just for that line), it will screw up the drawn selection for the rest of the document.

EDIT: In my case, I was using positive padding and negative text-indent to achieve soft wrapping.

@lishid
Copy link
Contributor Author

lishid commented Dec 14, 2021

Ok, how about this? This would always draw the selection pieces to include the left-most part of either the first line or the subsequent lines. I think that's likely the behavior that's the most desired in either situation.

@marijnh
Copy link
Member

marijnh commented Dec 14, 2021

I assume you meant Math.min(0, , ...)? As it is, the Math.min call won't have an effect.

FIX: Properly draw selections when negative text-indent is used for soft wrapping.
@lishid
Copy link
Contributor Author

lishid commented Dec 14, 2021

My bad! That's exactly what I meant.

@marijnh
Copy link
Member

marijnh commented Dec 14, 2021

Thanks, merged (minus the semicolon) as 97119e3

@marijnh marijnh closed this Dec 14, 2021
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.

2 participants