From 5bbf6acc587035947f6ca5490c6fbe0111dd9f7c Mon Sep 17 00:00:00 2001 From: dwdyer Date: Thu, 22 Nov 2007 20:06:08 +0000 Subject: [PATCH] Better fix for ISSUE#1031 (log messages not wrapping on changes pages). Multiple spaces are replaced with   (except for the last one) and single spaces are unchanged. This means significant whitespace is retained without prohibiting wrapping. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@6008 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Util.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 199c05af64..4b6c3cc6da 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -456,6 +456,14 @@ public class Util { else if(ch=='&') buf.append("&"); + else + if(ch==' ') { + // All spaces in a block of consecutive spaces are converted to + // non-breaking space ( ) except for the last one. This allows + // significant whitespace to be retained without prohibiting wrapping. + char nextCh = i+1 < text.length() ? text.charAt(i+1) : 0; + buf.append(nextCh==' ' ? " " : " "); + } else buf.append(ch); }