-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Allow decorations to be anchored to the end of lines #34441
Comments
Inline decorations are currently implemented quite poorly at this time via CSS before and after selectors. This is unfortunately one of the quirks that happens because of the poor implementation. The only way out is to reimplement on our side how inline decorations work, such that they are part of the view rendering logic and not something plucked on top via before/after selectors. |
Do you think this is something that's likely to happen in the near future? |
Yes, IMHO we need to address this. |
@alexandrudima is there any good documentation on that enum? I'm not sure I understand the values. |
@alexandrudima Thanks, sounds promising! I had tried different values, however I think it was before anchoring at the end of the line - maybe now ClosedOpen will solve the issue (assuming putting the cursor after the last character on the line will result in insertions before the decoration). I'll try it out and post back. @eamodio The comment on the surrounding type is slightly better than the one on the enum:
I believe the idea is that when the cursor is at the edge of a decoration and the user types a new character, should the it become part of the range, or not (Closed means not, Open means it should - the enum names represent the start and end). |
That enum maps its values to TrackedRangeStickiness You can think of decorations as an interval over text, with their boundaries always between characters:
The decoration above would sit on top of Decorations always have special cases when editing occurs precisely at their bounds. For example, when placing the cursor between
One way to think about it is that each boundary can "stick" to the character before or to the character after. Turns out there are two cases for the start and two cases for the end of the decoration. Something like this:
@jrieken and I have struggled for a few tens of minutes to come up with good names for the enum values, we decided to go with these math-type open/close when we opened them up in the API (I think it was a PR that did the real work, we just renamed them) :
|
I think this is another instance of this issue -- FYI GitLens does now specify Originally from @mcarpenterjr @ gitkraken/vscode-gitlens#176 (comment)
|
Finally got round to this. Setting ClosedOpen does seem to stop the issue and so far I haven't found any negative side-effects :-) |
I'm using text editor decorations to annotate the closing brackets of nested constructs to improve code readability for things like Flutter widgets (these methods have lots of nested calls, similar to React render methods):
Originally I anchored the decorations to the closing bracket, but when multiple items ended on the same line it was strange to have the decorations inserted between the users characters. So I tweaked this to instead always anchor them at the last character of the line, and stack them up (they appear as
// a // b // c
).It all generally works great, however because they're not actually anchored to the end of the line, but rather the character that happens to be at the end of the line, it's possible for the user to put the cursor behind the last character and type a new character, which appears after the decoration (for a brief period, until it gets updated by my code):
I don't think I can really fix this, unless Code had support for anchoring a decoration to the end of the line properly (without me just using the last character).
Is this something you'd consider? I appreciate I might not be using decorations for whatever it was designed for, but this feature has very positive feedback, I'd really like to make it work!
The text was updated successfully, but these errors were encountered: