From eb5870fd234fef41929cb93d55a1ef7c236f5a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kroi=C3=9F=2C=20Florian?= Date: Tue, 13 Aug 2024 15:09:16 +0200 Subject: [PATCH] Defer creation of dummy process until we actually have something to output (#1051) --- .../debug/debugmodel/DSPDebugTarget.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/org.eclipse.lsp4e.debug/src/org/eclipse/lsp4e/debug/debugmodel/DSPDebugTarget.java b/org.eclipse.lsp4e.debug/src/org/eclipse/lsp4e/debug/debugmodel/DSPDebugTarget.java index 454205ac4..4aaf2d77d 100644 --- a/org.eclipse.lsp4e.debug/src/org/eclipse/lsp4e/debug/debugmodel/DSPDebugTarget.java +++ b/org.eclipse.lsp4e.debug/src/org/eclipse/lsp4e/debug/debugmodel/DSPDebugTarget.java @@ -618,26 +618,25 @@ private CompletableFuture triggerUpdateThreads() { @Override public void output(OutputEventArguments args) { - boolean outputted = false; - DSPStreamsProxy dspStreamsProxy; - if (process == null) { - process(null); // create dummy process to have a console - } - dspStreamsProxy = process.getStreamsProxy(); String output = args.getOutput(); - if (args.getCategory() == null || OutputEventArgumentsCategory.CONSOLE.equals(args.getCategory()) + if (args.getCategory() == null // + || OutputEventArgumentsCategory.CONSOLE.equals(args.getCategory()) // || OutputEventArgumentsCategory.STDOUT.equals(args.getCategory())) { // TODO put this data in a different region with a different colour - dspStreamsProxy.getOutputStreamMonitor().append(output); - outputted = true; + getOrCreateStreamsProxy().getOutputStreamMonitor().append(output); } else if (OutputEventArgumentsCategory.STDERR.equals(args.getCategory())) { - dspStreamsProxy.getErrorStreamMonitor().append(output); - outputted = true; - } - if (!outputted && DSPPlugin.DEBUG) { + getOrCreateStreamsProxy().getErrorStreamMonitor().append(output); + } else if (DSPPlugin.DEBUG) { System.out.println("output: " + args); } + } + private DSPStreamsProxy getOrCreateStreamsProxy() { + if (process == null) { + // create dummy process to have a console + process(null); + } + return process.getStreamsProxy(); } @Override