Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1943. Mouse ButtonShift is not preserving the text selected. #1944

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Terminal.Gui/Views/TextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,7 @@ void Top_AlternateForwardKeyChanged (Key obj)
void ResetPosition ()
{
topRow = leftColumn = currentRow = currentColumn = 0;
selecting = false;
shiftSelecting = false;
StopSelecting ();
ResetCursorVisibility ();
}

Expand Down Expand Up @@ -4151,6 +4150,8 @@ void ProcMovePrev (ref int nCol, ref int nRow, Rune nRune)
}
}

bool isButtonShift;

///<inheritdoc/>
public override bool MouseEvent (MouseEvent ev)
{
Expand Down Expand Up @@ -4182,9 +4183,10 @@ public override bool MouseEvent (MouseEvent ev)
}

if (ev.Flags == MouseFlags.Button1Clicked) {
if (shiftSelecting) {
shiftSelecting = false;
selecting = false;
if (shiftSelecting && !isButtonShift) {
StopSelecting ();
} else if (!shiftSelecting && isButtonShift) {
isButtonShift = false;
}
ProcessMouseClick (ev, out _);
PositionCursor ();
Expand Down Expand Up @@ -4235,6 +4237,7 @@ public override bool MouseEvent (MouseEvent ev)
columnTrack = currentColumn;
} else if (ev.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ButtonShift)) {
if (!shiftSelecting) {
isButtonShift = true;
StartSelecting ();
}
ProcessMouseClick (ev, out _);
Expand All @@ -4243,8 +4246,7 @@ public override bool MouseEvent (MouseEvent ev)
columnTrack = currentColumn;
} else if (ev.Flags.HasFlag (MouseFlags.Button1Pressed)) {
if (shiftSelecting) {
shiftSelecting = false;
selecting = false;
StopSelecting ();
}
ProcessMouseClick (ev, out _);
PositionCursor ();
Expand Down