fix(tcsh): print literal newline char with leading space

it be like that sometimes, I also have no clue why this is necessary

resolves #5105
This commit is contained in:
Jan De Dobbeleer 2024-06-17 19:38:56 +02:00 committed by Jan De Dobbeleer
parent f817acf963
commit 0e45aa5997
2 changed files with 18 additions and 3 deletions

View file

@ -95,11 +95,13 @@ func (b *Block) Enabled() bool {
if b.Type == LineBreak {
return true
}
for _, segment := range b.Segments {
if segment.Enabled {
return true
}
}
return false
}
@ -107,6 +109,7 @@ func (b *Block) setEnabledSegments() {
wg := sync.WaitGroup{}
wg.Add(len(b.Segments))
defer wg.Wait()
for _, segment := range b.Segments {
go func(s *Segment) {
defer wg.Done()

View file

@ -115,13 +115,25 @@ func (e *Engine) pwd() {
}
func (e *Engine) newline() {
defer func() {
e.currentLineLength = 0
}()
// WARP terminal will remove \n from the prompt, so we hack a newline in
if e.isWarp() {
e.write(e.Writer.LineBreak())
} else {
e.write("\n")
return
}
e.currentLineLength = 0
// TCSH needs a space before the LITERAL newline character or it will not render correctly
// don't ask why, it be like that sometimes.
// https://unix.stackexchange.com/questions/99101/properly-defining-a-multi-line-prompt-in-tcsh#comment1342462_322189
if e.Env.Shell() == shell.TCSH {
e.write(` \n`)
return
}
e.write("\n")
}
func (e *Engine) isWarp() bool {