mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 09:18:01 +01:00
Fixes #1208. Now the selected text is overwritten if SelectedStart is greater than CursorPosition. (#1209)
This commit is contained in:
@@ -829,7 +829,7 @@ namespace Terminal.Gui {
|
||||
void SetSelectedStartSelectedLength ()
|
||||
{
|
||||
if (SelectedStart > -1 && point < SelectedStart) {
|
||||
start = point - SelectedStart + SelectedStart;
|
||||
start = point;
|
||||
} else {
|
||||
start = SelectedStart;
|
||||
}
|
||||
@@ -861,7 +861,8 @@ namespace Terminal.Gui {
|
||||
void DeleteSelectedText ()
|
||||
{
|
||||
ustring actualText = Text;
|
||||
int selStart = point < SelectedStart ? SelectedStart - point + SelectedStart : SelectedStart;
|
||||
SetSelectedStartSelectedLength ();
|
||||
int selStart = SelectedStart > -1 ? start : point;
|
||||
(var _, var len) = TextModel.DisplaySize (text, 0, selStart, false);
|
||||
(var _, var len2) = TextModel.DisplaySize (text, selStart, selStart + length, false);
|
||||
(var _, var len3) = TextModel.DisplaySize (text, selStart + length, actualText.RuneCount, false);
|
||||
|
||||
@@ -56,6 +56,16 @@ namespace Terminal.Gui {
|
||||
Assert.Null (_textField.SelectedText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectedStart_Greater_Than_CursorPosition_All_Selection_Is_Overwritten_On_Typing ()
|
||||
{
|
||||
_textField.SelectedStart = 19;
|
||||
_textField.CursorPosition = 12;
|
||||
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
|
||||
_textField.ProcessKey (new KeyEvent ((Key)0x75, new KeyModifiers ())); // u
|
||||
Assert.Equal ("TAB to jump u text fields.", _textField.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CursorPosition_With_Value_Less_Than_Zero_Changes_To_Zero ()
|
||||
{
|
||||
@@ -636,7 +646,6 @@ namespace Terminal.Gui {
|
||||
Assert.Equal ("TAB to jumusep between text fields.", _textField.Text);
|
||||
_textField.ProcessKey (new KeyEvent ((Key)0x64, new KeyModifiers ())); // d
|
||||
Assert.Equal ("TAB to jumusedp between text fields.", _textField.Text);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -653,7 +662,6 @@ namespace Terminal.Gui {
|
||||
Assert.Equal ("TAB to jumuseetween text fields.", _textField.Text);
|
||||
_textField.ProcessKey (new KeyEvent ((Key)0x64, new KeyModifiers ())); // d
|
||||
Assert.Equal ("TAB to jumusedtween text fields.", _textField.Text);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user