mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-81238 Packages: handle \b in outputs
Signed-off-by: Nikita.Ashihmin <nikita.ashihmin@jetbrains.com> GitOrigin-RevId: a243ab2bde91799d6499974a9dc8d5b16260edab
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1b210e9be4
commit
7d87cb8705
@@ -38,11 +38,11 @@ public class ProcessOutput {
|
||||
}
|
||||
|
||||
public void appendStdout(@Nullable String text) {
|
||||
myStdoutBuilder.append(text);
|
||||
appendWithBackspaceHandling(myStdoutBuilder, text);
|
||||
}
|
||||
|
||||
public void appendStderr(@Nullable String text) {
|
||||
myStderrBuilder.append(text);
|
||||
appendWithBackspaceHandling(myStderrBuilder, text);
|
||||
}
|
||||
|
||||
public @NotNull @NlsSafe String getStdout() {
|
||||
@@ -137,4 +137,28 @@ public class ProcessOutput {
|
||||
", stderr=" + myStderrBuilder +
|
||||
'}';
|
||||
}
|
||||
|
||||
private static void appendWithBackspaceHandling(@NotNull StringBuilder builder, @Nullable String text) {
|
||||
if (text == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.contains("\b")) {
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
if (c == '\b') {
|
||||
int length = builder.length();
|
||||
if (length > 0) {
|
||||
builder.deleteCharAt(length - 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user