Take care not to replace the trailing newlines with a space in the command output.
This is a better fix of issue #43407.
1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/commands/PreCommandPerformer.java Wed Jul 07 15:37:37 2004 +0000
1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/commands/PreCommandPerformer.java Wed Jul 07 16:03:30 2004 +0000
1.3 @@ -345,7 +345,7 @@
1.4 tend++;
1.5 whichElement = whichElement.substring(0, tindex) + ((tend < whichElement.length()) ? whichElement.substring(tend) : ""); // NOI18N
1.6 }
1.7 - String nl = (insertNewLine) ? "\n" : "".intern(); // NOI18N
1.8 + String nl = (insertNewLine) ? "\n" : " "; // NOI18N
1.9 int commaIndex = whichElement.indexOf(',');
1.10 if (commaIndex > 0) {
1.11 try {
1.12 @@ -366,12 +366,14 @@
1.13 ArrayList lastLines = null;
1.14 if (maxLastLines > 0) lastLines = new ArrayList();
1.15 boolean linesCut = false;
1.16 + boolean appendNewLine = false;
1.17 for (Enumeration enum = preCommandOutput[whichOutput].elements(); enum.hasMoreElements(); line++) {
1.18 String[] elements = (String[]) enum.nextElement();
1.19 if (elements.length > index && elements[index] != null) {
1.20 if (maxFirstLines > 0) {
1.21 if (line < maxFirstLines) {
1.22 - insertion.append(elements[index] + nl);
1.23 + if (appendNewLine) insertion.append(nl);
1.24 + insertion.append(elements[index]);
1.25 } else {
1.26 linesCut = true;
1.27 if (maxLastLines > 0) {
1.28 @@ -380,18 +382,22 @@
1.29 }
1.30 }
1.31 } else {
1.32 - insertion.append(elements[index] + nl);
1.33 + if (appendNewLine) insertion.append(nl);
1.34 + insertion.append(elements[index]);
1.35 + }
1.36 + appendNewLine = true;
1.37 + }
1.38 + }
1.39 + if (linesCut) {
1.40 + insertion.append("...");
1.41 + if (lastLines != null) {
1.42 + for (int i = 0; i < lastLines.size(); i++) {
1.43 + insertion.append(nl);
1.44 + insertion.append(lastLines.get(i));
1.45 }
1.46 }
1.47 }
1.48 - if (linesCut) {
1.49 - insertion.append("..." + nl);
1.50 - if (lastLines != null) {
1.51 - for (int i = 0; i < lastLines.size(); i++) {
1.52 - insertion.append(lastLines.get(i) + nl);
1.53 - }
1.54 - }
1.55 - }
1.56 + if (insertNewLine) insertion.append(nl); // End with a new line
1.57 } catch (NumberFormatException exc) {
1.58 // Ignored
1.59 }