Skip to content

Commit

Permalink
Merge branch 'v2_develop' into v2_tabview-frame-fix_2882
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp authored Dec 7, 2023
2 parents 0da7866 + 8f1b5ac commit 5cbc5a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Terminal.Gui/Views/TextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,9 @@ void UpdateWrapModel ([CallerMemberName] string? caller = null)
_selectionStartRow = nStartRow;
_selectionStartColumn = nStartCol;
_wrapNeeded = true;
}

SetNeedsDisplay();
}
if (_currentCaller != null)
throw new InvalidOperationException ($"WordWrap settings was changed after the {_currentCaller} call.");
}
Expand Down
31 changes: 31 additions & 0 deletions UnitTests/Views/TextViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6977,5 +6977,36 @@ public void WordWrap_True_LoadStream_New_Text ()
Assert.True (_textView.WordWrap);
}
}

[Theory]
[TextViewTestsAutoInitShutdown]
[InlineData (Key.Delete)]
[InlineData (Key.DeleteChar)]
public void WordWrap_Draw_Typed_Keys_After_Text_Is_Deleted (Key del)
{
Application.Top.Add (_textView);
_textView.Text = "Line 1.\nLine 2.";
_textView.WordWrap = true;
Application.Begin (Application.Top);

Assert.True (_textView.WordWrap);
TestHelpers.AssertDriverContentsWithFrameAre (@"
Line 1.
Line 2.", output);

Assert.True (_textView.ProcessKey (new KeyEvent (Key.End | Key.ShiftMask, new KeyModifiers () { Shift = true })));
Assert.Equal ("Line 1.", _textView.SelectedText);

Assert.True (_textView.ProcessKey (new KeyEvent (del, new KeyModifiers ())));
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre ("Line 2.", output);

Assert.True (_textView.ProcessKey (new KeyEvent (Key.H, new KeyModifiers ())));
Assert.NotEqual (Rect.Empty, _textView._needsDisplayRect);
Application.Refresh ();
TestHelpers.AssertDriverContentsWithFrameAre (@"
H
Line 2.", output);
}
}
}

0 comments on commit 5cbc5a9

Please sign in to comment.