1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-04-14 05:15:43 +02:00

Refactor commands output

This commit is contained in:
Alex Plate 2022-10-31 09:51:37 +02:00
parent 689aa4cf95
commit 05852b07c6
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 8 additions and 2 deletions
src/main/java/com/maddyhome/idea/vim/group
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/helper

View File

@ -40,6 +40,7 @@ import com.maddyhome.idea.vim.command.Command;
import com.maddyhome.idea.vim.command.VimStateMachine;
import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.ex.InvalidCommandException;
import com.maddyhome.idea.vim.helper.EngineStringHelperKt;
import com.maddyhome.idea.vim.helper.UiHelper;
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
import com.maddyhome.idea.vim.newapi.IjVimEditor;
@ -262,10 +263,9 @@ public class ProcessGroup extends VimProcessGroupBase {
if (exitCode != null && exitCode != 0) {
VimPlugin.showMessage("shell returned " + exitCode);
VimPlugin.indicateError();
return output.getStderr() + output.getStdout();
}
return output.getStdout();
return EngineStringHelperKt.removeAsciiColorCodes(output.getStderr() + output.getStdout());
}, "IdeaVim - !" + command, true, ((IjVimEditor) editor).getEditor().getProject());
}

View File

@ -53,3 +53,9 @@ object EngineStringHelper {
return c.toString()
}
}
// https://stackoverflow.com/a/14652763/3124227
fun String.removeAsciiColorCodes(): String {
return this.replace("\u001B\\[[;\\d]*m".toRegex(), "")
}