Skip to content

Commit

Permalink
refactor: remove linebreak block type
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Sep 7, 2024
1 parent 3a531ad commit 522f16d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
6 changes: 0 additions & 6 deletions src/config/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/config/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}}},
Expand Down
15 changes: 1 addition & 14 deletions src/prompt/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,6 @@ func (e *Engine) getTitleTemplateText() string {
func (e *Engine) renderBlock(block *config.Block, cancelNewline bool) bool {
defer e.applyPowerShellBleedPatch()

// 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() {
Expand All @@ -197,7 +184,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
Expand Down

0 comments on commit 522f16d

Please sign in to comment.