Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorKarl <5079870+PreferLinux@users.noreply.github.com>2020-07-29 15:28:16 +0300
committerGitHub <noreply@github.com>2020-07-29 15:28:16 +0300
commit957d1942d131f0dfd46b79b3cf3f761bfb783197 (patch)
tree3143b1425f93d3351ac9d58360d805f62d073387 /mcs
parent4c7c1181cfa4b0600928417a801133b02aed7416 (diff)
Fix Line problem with wrapping and tabs (#20112)
Also adds a minor improvement to line wrapping, by not updating the wrap position when it can only move it earlier. This means when processing end-of-wrapped-line whitespace that it doesn't get adjusted every time. Also doesn't update the previous wrap position, but that shouldn't be used in this situation as it is only for wrapping after dashes. The real problem that this fixes is that wrapping a line at a point such that there was whitespace including a tab after the wrap position could cause an infinite loop. Without the fix, with a wrap_pos > 0 (normal), it only split the line after reaching non-whitespace. In most situations that was OK as we norwally wrap after whitespace. However a tab is whitespace we wrap before. Once pos was equal to wrap_pos it stopped incrementing pos as it was now at the split position and therefore it shouldn't change. But it didn't set split_tag, so didn't split, and therefore didn't exit the outer loop.
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/Line.cs8
1 files changed, 6 insertions, 2 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/Line.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/Line.cs
index 7e0213be860..c0b5072a9ca 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/Line.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/Line.cs
@@ -719,7 +719,7 @@ namespace System.Windows.Forms
if (doc.Wrap) {
// FIXME: Technically there are multiple no-break spaces, not just the main one.
- if ((Char.IsWhiteSpace (c) && c != '\u00A0') || c == '-' || c == '\u2013' || c == '\u2014') {
+ if (wrap_pos <= pos && ((Char.IsWhiteSpace (c) && c != '\u00A0') || c == '-' || c == '\u2013' || c == '\u2014')) {
// Primarily break on dashes or whitespace other than a no-break space.
prev_wrap_pos = wrap_pos;
if (c == '\t') {
@@ -738,11 +738,15 @@ namespace System.Windows.Forms
if (Char.IsWhiteSpace (c)) {
if (wrap_pos > pos) {
while (wrap_pos < text.Length && Char.IsWhiteSpace (text [wrap_pos]) && text [wrap_pos] != '\t') {
+ // Leave whitespace other than tabs on the end of this line.
wrap_pos++;
}
pos++;
wrapped = true;
- // don't try pulling more into this line, but keep looping to deal with the rest of the widths and tags
+ // don't try pulling more into this line, but keep looping to deal with the rest of the widths and tags that will be left on the line
+ } else {
+ // At the wrap position, so split the line. c is a tab.
+ split_tag = tag;
}
} else {
if (wrap_pos > pos && pos > 0) {