Skip to content

Commit

Permalink
- Fixed a crash in previous commits
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Dec 22, 2018
1 parent 38a70b1 commit 2206814
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Codist/Helpers/TextEditorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public static ITextSnapshot Edit<TView>(this TView view, Action<TView, ITextEdit
using (var edit = view.TextSnapshot.TextBuffer.CreateEdit()) {
action(view, edit);
if (edit.HasEffectiveChanges) {
edit.Apply();
return edit.Snapshot;
return edit.Apply();
}
return null;
}
Expand All @@ -111,8 +110,7 @@ public static ITextSnapshot EditSelection<TView>(this TView view, Action<TView,
action(view, edit, item);
}
if (edit.HasEffectiveChanges) {
edit.Apply();
return edit.Snapshot;
return edit.Apply();
}
return null;
}
Expand Down Expand Up @@ -224,6 +222,10 @@ public static void SelectNode(this ITextView view, Microsoft.CodeAnalysis.Syntax
}

public static void SelectSpan(this ITextView view, SnapshotSpan span) {
if (view.TextSnapshot != span.Snapshot) {
// should not be here
span = new SnapshotSpan(view.TextSnapshot, span.Span);
}
view.ViewScroller.EnsureSpanVisible(span, EnsureSpanVisibleOptions.ShowStart);
view.Selection.Select(span, false);
view.Caret.MoveTo(span.End);
Expand Down

0 comments on commit 2206814

Please sign in to comment.