Inline hints: Double click to insert hint can overwrite buffer of previous inserted hint if done too quickly#60204
Merged
akhera99 merged 7 commits intodotnet:mainfrom Mar 17, 2022
Conversation
…an of the text change so you get the updated buffer
JoeRobich
approved these changes
Mar 16, 2022
|
|
||
| private readonly ITextView _textView; | ||
| private readonly SnapshotSpan _span; | ||
| private readonly ITrackingSpan? _trackingSpan; |
Contributor
There was a problem hiding this comment.
i don't think you need this.
| var subjectBuffer = _span.Snapshot.TextBuffer; | ||
|
|
||
| if (subjectBuffer.CurrentSnapshot.Length > replacementValue.Span.End) | ||
| var updatedSpan = _trackingSpan!.GetSpan(subjectBuffer.CurrentSnapshot); |
Contributor
There was a problem hiding this comment.
i don't think youneed this. you have a _span to begin with. it can be tracked forward to the current ITextSnapshot right here. Happy to discuss how this works tomorrow if you're interested :)
| Internal.Log.Logger.Log(FunctionId.Inline_Hints_DoubleClick, | ||
| Logger.Log(FunctionId.Inline_Hints_DoubleClick, | ||
| $"replacement span end:{replacementValue.Span.End} is greater than or equal to current snapshot length:{subjectBuffer.CurrentSnapshot.Length}"); | ||
| } |
Contributor
There was a problem hiding this comment.
should not need this block at all. we'll be able to remove this entirely.
| hint, Format, _textView, tagSpan, trackingSpan, _taggerProvider, _formatMap, classify); | ||
|
|
||
| hintTagSpan = new TagSpan<IntraTextAdornmentTag>(tagSpan, hintUITag); | ||
| _cache[i] = (_cache[i].mappingTagSpan, hintTagSpan); |
Contributor
There was a problem hiding this comment.
should be able to restore all this to the original code.
… move the span forward to the most recent version
| Internal.Log.Logger.Log(FunctionId.Inline_Hints_DoubleClick, | ||
| $"replacement span end:{replacementValue.Span.End} is greater than or equal to current snapshot length:{subjectBuffer.CurrentSnapshot.Length}"); | ||
| } | ||
| var currentSnapshotSpan = _span.TranslateTo(subjectBuffer.CurrentSnapshot, SpanTrackingMode.EdgeExclusive); |
Contributor
There was a problem hiding this comment.
doc that 'EdgeExclusive' is just what we picked by default but that we could revise it if it turns out the behaviour isn't ideal for some scenario we didn't consider.
CyrusNajmabadi
approved these changes
Mar 17, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #59843
Uses an ITrackingSpan to recalculate the span for each tag