Skip to content

Commit

Permalink
fix(tcsh): print literal newline char with leading space
Browse files Browse the repository at this point in the history
it be like that sometimes, I also have no clue why this is necessary

resolves #5105
  • Loading branch information
JanDeDobbeleer committed Jun 17, 2024
1 parent f817acf commit 0e45aa5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/engine/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,21 @@ func (b *Block) Enabled() bool {
if b.Type == LineBreak {
return true
}

for _, segment := range b.Segments {
if segment.Enabled {
return true
}
}

return false
}

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()
Expand Down
18 changes: 15 additions & 3 deletions src/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0e45aa5

Please sign in to comment.