From 6b9c7c1c4735b4eda01192bc82a54dae04ef768e Mon Sep 17 00:00:00 2001 From: Robbie Knuth Date: Mon, 19 Sep 2016 12:41:05 -0700 Subject: [PATCH 1/3] Textboxes should take whitespace into account when calculating size. --- src/Avalonia.Controls/Presenters/TextPresenter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index f9c55e1f3b..d3cf4e5509 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -219,7 +219,7 @@ namespace Avalonia.Controls.Presenters { var text = Text; - if (!string.IsNullOrWhiteSpace(text)) + if (!string.IsNullOrEmpty(text)) { return base.MeasureOverride(availableSize); } From 507bc51b595337a3d3db99eb3f72d2c77ba05112 Mon Sep 17 00:00:00 2001 From: Robbie Knuth Date: Mon, 19 Sep 2016 12:43:26 -0700 Subject: [PATCH 2/3] Handle special case of deleting carriage returns and linefeeds in multiline textboxes. --- src/Avalonia.Controls/TextBox.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index ed73472c49..b86d3e0d4e 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -379,8 +379,20 @@ namespace Avalonia.Controls if (!DeleteSelection() && CaretIndex > 0) { - SetTextInternal(text.Substring(0, caretIndex - 1) + text.Substring(caretIndex)); - --CaretIndex; + var removedCharacters = 1; + // handle deleting /r/n + // you don't ever want to leave a dangling /r around. So, if deleting /n, check to see if + // a /r should also be deleted. + if (CaretIndex > 1 && + text[CaretIndex - 1] == '\n' && + text[CaretIndex - 2] == '\r') + { + removedCharacters = 2; + } + + SetTextInternal(text.Substring(0, caretIndex - removedCharacters) + text.Substring(caretIndex)); + CaretIndex -= removedCharacters; + SelectionStart = SelectionEnd = CaretIndex; } break; @@ -393,7 +405,18 @@ namespace Avalonia.Controls if (!DeleteSelection() && caretIndex < text.Length) { - SetTextInternal(text.Substring(0, caretIndex) + text.Substring(caretIndex + 1)); + var removedCharacters = 1; + // handle deleting /r/n + // you don't ever want to leave a dangling /r around. So, if deleting /n, check to see if + // a /r should also be deleted. + if (CaretIndex < text.Length - 1 && + text[caretIndex + 1] == '\n' && + text[caretIndex] == '\r') + { + removedCharacters = 2; + } + + SetTextInternal(text.Substring(0, caretIndex) + text.Substring(caretIndex + removedCharacters)); } break; From 96bd07e193bf4b428cbc2965b27b465a991e8b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Wed, 21 Sep 2016 21:43:25 +0200 Subject: [PATCH 3/3] Use mono 4.4.2 until latest 4.6 is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=44323 https://bugzilla.xamarin.com/show_bug.cgi?id=44402 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af7d5dbebf..9693d21b7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ os: - linux - osx mono: - - latest + - 4.4.2 script: - ./build.sh --target "Travis" --platform "Mono" --configuration "Release" notifications: