Skip to content

Commit

Permalink
! Refactored ExpandSelectionToLine
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Mar 27, 2021
1 parent 0cb8824 commit 6ce7f55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Codist/Helpers/TextEditorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ public static bool Mark<TKey>(this IPropertyOwner owner, TKey mark) {

#region Selection
public static void ExpandSelectionToLine(this ITextView view) {
view.ExpandSelectionToLine(true);
view.ExpandSelectionToLine(false);
}
public static void ExpandSelectionToLine(this ITextView view, bool includeLineBreak) {
public static void ExpandSelectionToLine(this ITextView view, bool excludeLineBreak) {
var start = view.TextSnapshot.GetLineFromPosition(view.Selection.Start.Position).Start;
var end = view.Selection.End.Position;
var endLine = view.TextSnapshot.GetLineFromPosition(end);
if (endLine.Start != end) {
// if selection not ended in line break, expand to line break
end = includeLineBreak ? endLine.EndIncludingLineBreak : endLine.End;
end = excludeLineBreak ? endLine.End : endLine.EndIncludingLineBreak;
}
view.Selection.Select(new SnapshotSpan(start, end), false);
}
Expand Down
2 changes: 1 addition & 1 deletion Codist/SmartBars/SmartBar.CommonEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ partial class SmartBar

static void ExecuteAndFind(CommandContext ctx, string command, string text) {
if (ctx.RightClick) {
ctx.View.ExpandSelectionToLine(false);
ctx.View.ExpandSelectionToLine(true);
}
ctx.KeepToolBar(false);
TextEditorHelper.ExecuteEditorCommand(command);
Expand Down

0 comments on commit 6ce7f55

Please sign in to comment.