Browse Source

Fixes #1943. Mouse ButtonShift is not preserving the text selected when clicking on another position. (#1944)

BDisp 3 years ago
parent
commit
7ade996ef4
1 changed files with 9 additions and 7 deletions
  1. 9 7
      Terminal.Gui/Views/TextView.cs

+ 9 - 7
Terminal.Gui/Views/TextView.cs

@@ -1468,8 +1468,7 @@ namespace Terminal.Gui {
 		void ResetPosition ()
 		{
 			topRow = leftColumn = currentRow = currentColumn = 0;
-			selecting = false;
-			shiftSelecting = false;
+			StopSelecting ();
 			ResetCursorVisibility ();
 		}
 
@@ -4151,6 +4150,8 @@ namespace Terminal.Gui {
 			}
 		}
 
+		bool isButtonShift;
+
 		///<inheritdoc/>
 		public override bool MouseEvent (MouseEvent ev)
 		{
@@ -4182,9 +4183,10 @@ namespace Terminal.Gui {
 			}
 
 			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 ();
@@ -4235,6 +4237,7 @@ namespace Terminal.Gui {
 				columnTrack = currentColumn;
 			} else if (ev.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ButtonShift)) {
 				if (!shiftSelecting) {
+					isButtonShift = true;
 					StartSelecting ();
 				}
 				ProcessMouseClick (ev, out _);
@@ -4243,8 +4246,7 @@ namespace Terminal.Gui {
 				columnTrack = currentColumn;
 			} else if (ev.Flags.HasFlag (MouseFlags.Button1Pressed)) {
 				if (shiftSelecting) {
-					shiftSelecting = false;
-					selecting = false;
+					StopSelecting ();
 				}
 				ProcessMouseClick (ev, out _);
 				PositionCursor ();