Skip to content

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
akhera99:bugs/59843_inline_hints
Mar 17, 2022
Merged

Inline hints: Double click to insert hint can overwrite buffer of previous inserted hint if done too quickly#60204
akhera99 merged 7 commits intodotnet:mainfrom
akhera99:bugs/59843_inline_hints

Conversation

@akhera99
Copy link
Copy Markdown
Member

Fixes: #59843

Uses an ITrackingSpan to recalculate the span for each tag

@akhera99 akhera99 requested a review from a team as a code owner March 16, 2022 20:41
@akhera99 akhera99 requested a review from a team March 16, 2022 20:41
@ghost ghost added the Area-IDE label Mar 16, 2022
@akhera99 akhera99 marked this pull request as draft March 16, 2022 20:42
@akhera99 akhera99 requested a review from ryzngard March 16, 2022 20:42

private readonly ITextView _textView;
private readonly SnapshotSpan _span;
private readonly ITrackingSpan? _trackingSpan;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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}");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be able to restore all this to the original code.

… move the span forward to the most recent version
@akhera99 akhera99 marked this pull request as ready for review March 17, 2022 16:26
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@akhera99 akhera99 enabled auto-merge March 17, 2022 17:57
@akhera99 akhera99 merged commit bab9471 into dotnet:main Mar 17, 2022
@ghost ghost added this to the Next milestone Mar 17, 2022
@allisonchou allisonchou modified the milestones: Next, 17.2.P3 Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in parameter hints when inserting argument name

4 participants