This file contains 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
//// Moving to a new visual line | |
// Assuming you have ITextView textView | |
// 1. Assuming you have the new line number | |
var bufferLine = textView.TextSnapshot.GetLineFromLineNumber(lineNumber); | |
var viewLine = textView.GetTextViewLineContainingBufferPosition(bufferLine.Start); | |
textView.Caret.MoveTo(viewLine); // preserves x coordinate |
This file contains 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
//// Using the caret directly | |
// assuming you have ITextView textView | |
// assuming you have the int line/offset (where offset is from the start of the line) | |
var position = textView.TextSnapshot.GetLineFromLineNumber(line) + offset; | |
textView.Caret.MoveTo(position); | |
textView.Selection.Select(new SnapshotSpan(position, position), false); |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.Composition; | |
using System.Linq; | |
using System.Windows.Media; | |
using Microsoft.VisualStudio.ApplicationModel.Environments; | |
using Microsoft.VisualStudio.Text; | |
using Microsoft.VisualStudio.Text.Classification; | |
using Microsoft.VisualStudio.Utilities; |
This file contains 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
testing gist |
NewerOlder