how to enable `\r` in TerminalExecutionConsole when running commands which don't output `\r`

I'm working on an IDEA plugin for Jenkins X: https://github.com/jenkins-x/jx-intellj-plugin and we're trying to open an interactive terminal using TerminalExecutionConsole which kinda works:

https://github.com/jenkins-x/jx-intellj-plugin/blob/master/src/main/java/io/jenkins/x/idea/plugin/actions/ConsoleViewAnActionSupport.java#L64-L93

However the output never generates any `/r` characters so things wrap oddly in the UI (see below). I wonder if anyone had any bright ideas on how to configure the TerminalExecutionConsole / OSProcessHandler to deal with this? Note that the command being run is a go binary which doesn't appear to output `\r` but just `\n` for newlines. 

4
1 comment

In my case the problem was not that the process didn't output `\r` (though I don't remember outputting it), but that the default settings of `OSProcessHandler` was actively removing them. I have fixed this by overriding `OSProcessHandler.readerOptions()` to return:

override fun splitToLines(): Boolean = false

override fun sendIncompleteLines(): Boolean = true

override fun policy(): BaseDataReader.SleepingPolicy = BaseDataReader.SleepingPolicy.BLOCKING

override fun withSeparators(): Boolean = true

Initially I have implemented a special readers which replace `\n` with `\r\n`, but I didn't use that after all. The full code is here, if anybody is interested.

0

Please sign in to leave a comment.