fix(pwsh): only clear console after block write

This commit is contained in:
Jan De Dobbeleer 2021-04-21 21:20:18 +02:00 committed by Jan De Dobbeleer
parent b11b69f0e8
commit 3b7b854fdc

View file

@ -19,13 +19,6 @@ type engine struct {
func (e *engine) write(text string) { func (e *engine) write(text string) {
e.console.WriteString(text) e.console.WriteString(text)
// Due to a bug in Powershell, the end of the line needs to be cleared.
// If this doesn't happen, the portion after the prompt gets colored in the background
// color of the line above the new input line. Clearing the line fixes this,
// but can hopefully one day be removed when this is resolved natively.
if e.ansi.shell == pwsh || e.ansi.shell == powershell5 {
e.console.WriteString(e.ansi.clearEOL)
}
} }
func (e *engine) string() string { func (e *engine) string() string {
@ -86,6 +79,13 @@ func (e *engine) renderBlock(block *Block) {
case RPrompt: case RPrompt:
e.rprompt = block.renderSegments() e.rprompt = block.renderSegments()
} }
// Due to a bug in Powershell, the end of the line needs to be cleared.
// If this doesn't happen, the portion after the prompt gets colored in the background
// color of the line above the new input line. Clearing the line fixes this,
// but can hopefully one day be removed when this is resolved natively.
if e.ansi.shell == pwsh || e.ansi.shell == powershell5 {
e.write(e.ansi.clearEOL)
}
} }
// debug will loop through your config file and output the timings for each segments // debug will loop through your config file and output the timings for each segments