diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index d0bcd1872ae..a37b0b0db25 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -154,27 +154,40 @@ public class CommandLauncher { closure.runNonBlocking(); byte buffer[] = new byte[1024]; int nbytes; + int waited = 0; + boolean flushed = false; while (!monitor.isCanceled() && closure.isAlive()) { nbytes = 0; try { if ( errInPipe.available() > 0 ) { nbytes = errInPipe.read(buffer); err.write(buffer, 0, nbytes); - err.flush(); } if ( inputPipe.available() > 0 ) { nbytes = inputPipe.read(buffer); output.write(buffer, 0, nbytes); - output.flush(); } } catch( IOException e) { } monitor.worked(0); if (nbytes == 0) { + //DELAY * 10 is half a second with no new input, flush anything thats waiting + if( !flushed && waited > DELAY * 10 ){ + try { + err.flush(); + output.flush(); + flushed = true; + } catch (IOException e1) { + } + waited = 0; + } try { - Thread.sleep(DELAY); + waited += DELAY; + Thread.sleep(DELAY); } catch (InterruptedException ie) { } + } else { + flushed = false; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java index 56b7cf16d58..5151f39d6c5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java @@ -72,6 +72,9 @@ public class BuildConsolePartitioner */ public void appendToDocument(final String text, final BuildConsoleStream stream) { + if( text.length() == 0 ) + return; + Runnable r = new Runnable() { public void run() { @@ -298,7 +301,8 @@ public class BuildConsolePartitioner } public void flush() throws IOException { - appendToDocument(readBuffer(), fStream); + if( fBuffer.length() > 0 ) + appendToDocument(readBuffer(), fStream); fManager.showConsole(); } @@ -308,7 +312,8 @@ public class BuildConsolePartitioner public synchronized void write(byte[] b, int off, int len) throws IOException { super.write(b, off, len); - flush(); + if( fBuffer.length() > 4096 ) + flush(); } }