microsoft / microsoft/VSExtensibility
SetSelections doesn't change the caret position, it is instead adding additional caret(s) on top of the current one
Open
@olegtk is already working on this.
Since Aug 6, 2024.
- Dominant language
- C#
- Stars
- 440
- Forks
- 63
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 1
Description
When using textview.AsEditable.SetSelections it is adding a new caret selection on top of the current one the editor has.
Repro
The extension command is going to set the caret selection to 5, you can notice the fifth character appears as a blue caret, while the old caret position is still kept (and respected) as the red caret.
https://github.com/user-attachments/assets/f0a1ab8d-300e-4c2f-b666-94a6ce5a8e9f
Code
await Extensibility.Editor().EditAsync(
batch =>
{
var caret5 = new TextPosition(textView.Document, 5);
textView.AsEditable(batch).SetSelections([new Selection(activePosition: caret5, anchorPosition: caret5, insertionPosition: caret5)]);
},
cancellationToken);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.