From e79b99503031929e47d03279ac2b2d0e515f4120 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Mon, 26 Aug 2024 16:53:56 +0200 Subject: [PATCH] refactor: remove linebreak block type --- src/config/block.go | 6 ------ src/config/block_test.go | 1 - src/prompt/engine.go | 15 +-------------- 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/config/block.go b/src/config/block.go index 0cf4f861e4d1..dc8a81d46558 100644 --- a/src/config/block.go +++ b/src/config/block.go @@ -18,8 +18,6 @@ type Overflow string const ( // Prompt writes one or more Segments Prompt BlockType = "prompt" - // LineBreak creates a line break in the prompt - LineBreak BlockType = "newline" // RPrompt is a right aligned prompt RPrompt BlockType = "rprompt" // Left aligns left @@ -53,10 +51,6 @@ func (b *Block) Init(env runtime.Environment) { } func (b *Block) Enabled() bool { - if b.Type == LineBreak { - return true - } - for _, segment := range b.Segments { if segment.Enabled { return true diff --git a/src/config/block_test.go b/src/config/block_test.go index c72a29517c2c..34d8fe7c3061 100644 --- a/src/config/block_test.go +++ b/src/config/block_test.go @@ -13,7 +13,6 @@ func TestBlockEnabled(t *testing.T) { Segments []*Segment Expected bool }{ - {Case: "line break block", Expected: true, Type: LineBreak}, {Case: "prompt enabled", Expected: true, Type: Prompt, Segments: []*Segment{{Enabled: true}}}, {Case: "prompt disabled", Expected: false, Type: Prompt, Segments: []*Segment{{Enabled: false}}}, {Case: "prompt enabled multiple", Expected: true, Type: Prompt, Segments: []*Segment{{Enabled: false}, {Enabled: true}}}, diff --git a/src/prompt/engine.go b/src/prompt/engine.go index 30949a51a91b..19ae35781f47 100644 --- a/src/prompt/engine.go +++ b/src/prompt/engine.go @@ -163,19 +163,6 @@ func (e *Engine) getTitleTemplateText() string { func (e *Engine) renderBlock(block *config.Block, cancelNewline bool) bool { defer e.patchPowerShellBleed() - // This is deprecated but we leave it in to not break configs - // It is encouraged to use "newline": true on block level - // rather than the standalone linebreak block - if block.Type == config.LineBreak { - // do not print a newline to avoid a leading space - // when we're printing the first primary prompt in - // the shell - if !cancelNewline { - e.writeNewline() - } - return false - } - block.Init(e.Env) if !block.Enabled() { @@ -196,7 +183,7 @@ func (e *Engine) renderBlock(block *config.Block, cancelNewline bool) bool { return false } - switch block.Type { //nolint:exhaustive + switch block.Type { case config.Prompt: if block.Alignment == config.Left { e.currentLineLength += length