-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Makes mouse/left/right navigation skip injected text. Also fixes bracket decoration bug. #128140
Conversation
1428c58
to
c8118a4
Compare
…position-normalization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but very complex! Took me quite a while to understand.
I've pushed the following changes directly:
- avoid allocating a Map and strings to set as keys every time the view state is set, especially since 90% or more of the time the calls to
viewModel.normalizePosition
will be a no-op (lines without injected text and without wrapping). Doing now the same optimization directly in code. - removes check for converting model range to view range that was added to fix Decorations that are ending on word-wrapped line leak to the next line whitespace #50163 since this is no longer necessary thanks to the affinity.
- in
normalizePosition
, I found it easier to handle the Left and Right affinities directly in the method, without converting to a model position and back. Maybe I'm missing something, but that seemed to be correct.
Let me know how you feel about my changes and if they seem correct to you, then please merge.
There is one follow-up item, but we can file it under an issue separately:
- If we want to move over inline completions to use injected text, we must figure out how to set
ITextContentData.mightBeForeignElement
to true for injected text or, even better, add a new property e.g.ITextContentData.injectedTextDecorationId?: string | null
. This should then be adopted ininlineCompletionsHoverParticipant.ts
. The hover participant wants to know if the mouse is over injected text. This information needs to be captured in_doHitTest
, around doing normalization.
Unfortuntately, I think this is not correct. Multiple injected texts might be injected at the same model position. Then you need to go at the start/end of the first/last injected text at that model position. When no position affinity is set (=none), there is nothing against setting a cursor between injected texts that are injected to the same position. Even a wrapping point could be immediately before/after an injected text. Left/right normalization must skip it, otherwise move left/right is not going to work properly. |
👍 Aha! Very good point! I think
Could that be resolved by invoking
I think this would be correct, but I have this intuition that this might be error-prone (or lossy?). If we ever want to add text elision, doing the roundtrip might bring up more problems. |
You mean for both left/right/no-affinity normalization or only for no-affinity? |
…th multiple touching injected texts and add a test with this case
This is what I meant -- e03e480 |
Cool! Thanks for the work! |
Please don't review yet, there is a bug.Fixed.