diff --git a/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java b/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java index 108a0b766f13a..a75be2677c1bd 100644 --- a/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java +++ b/platform/platform-impl/src/com/intellij/execution/wsl/WSLDistribution.java @@ -221,6 +221,18 @@ public ProcessOutput copyFromWsl(@NotNull String wslPath, public @NotNull T patchCommandLine(@NotNull T commandLine, @Nullable Project project, @NotNull WSLCommandLineOptions options) throws ExecutionException { + return patchCommandLine(commandLine, project, options, 0); + } + + /** + * Works like {@link #patchCommandLine(GeneralCommandLine, Project, WSLCommandLineOptions)}, + * but in addition it allows to workaround WSL1 problem + * Output from WSL command pipeline is randomly truncated + */ + public @NotNull T patchCommandLine(@NotNull T commandLine, + @Nullable Project project, + @NotNull WSLCommandLineOptions options, + double sleepTimeoutSec) throws ExecutionException { logCommandLineBefore(commandLine, options); Path executable = getExecutablePath(); boolean launchWithWslExe = options.isLaunchWithWslExe() || executable == null; @@ -282,6 +294,9 @@ public void startNotified(@NotNull ProcessEvent event) { commandLine.getParametersList().clearAll(); String linuxCommandStr = StringUtil.join(linuxCommand, " "); + if (sleepTimeoutSec > 0) { + linuxCommandStr += " && sleep " + sleepTimeoutSec; + } if (wslExe != null) { commandLine.setExePath(wslExe.toString()); commandLine.addParameters("--distribution", getMsId()); @@ -338,7 +353,7 @@ private void logCommandLineAfter(@NotNull GeneralCommandLine commandLine) { return file != null ? file.toPath() : null; } - public static @NotNull List buildLinuxCommand(@NotNull GeneralCommandLine commandLine, boolean executeCommandInShell) { + private static @NotNull List buildLinuxCommand(@NotNull GeneralCommandLine commandLine, boolean executeCommandInShell) { List command = ContainerUtil.concat(List.of(commandLine.getExePath()), commandLine.getParametersList().getList()); return new ArrayList<>(ContainerUtil.map(command, executeCommandInShell ? CommandLineUtil::posixQuote : Functions.identity())); }