Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions test/themes/powerline.base.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,46 @@ function local_setup_file() {
load "${BASH_IT?}/themes/powerline/powerline.base.bash"
}

# Stub a no-op segment so we can run __powerline_prompt_command without
# sourcing every plugin that the default segments depend on.
function __powerline_noop_prompt() { :; }
# _save-and-reload-history is called unconditionally; stub it out.
function _save-and-reload-history() { :; }

# --- __powerline_prompt_command: missing-newline handler (fixes #2372) ---

@test "powerline base: __powerline_prompt_command overflows the line and returns to column 1" {
COLUMNS=20
POWERLINE_PROMPT=("noop")
run __powerline_prompt_command

local expected
expected="$(printf '%*s\r' "$((COLUMNS - 1))" '')"
assert_output --partial "${expected}"
}

@test "powerline base: __powerline_prompt_command missing-newline sequence is first output" {
COLUMNS=20
POWERLINE_PROMPT=("noop")
run __powerline_prompt_command

# Confirm the padding+carriage-return appears at the very start, meaning it
# is a direct printf rather than anything embedded in PS1 or segments.
local prefix
prefix="$(printf '%*s\r' "$((COLUMNS - 1))" '')"
[[ "${output}" == "${prefix}"* ]]
}

@test "powerline base: __powerline_prompt_command falls back to 80 columns when COLUMNS is unset" {
unset COLUMNS
POWERLINE_PROMPT=("noop")
run __powerline_prompt_command

local expected
expected="$(printf '%*s\r' 79 '')"
assert_output --partial "${expected}"
}

function local_setup() {
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0
Expand Down
5 changes: 5 additions & 0 deletions themes/powerline/powerline.base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ function __powerline_prompt_command() {
local last_status="$?" ## always the first
local info prompt_color segment prompt

# If the previous command left output without a trailing newline, overflow
# the rest of the line with spaces so the terminal auto-wraps the cursor
# onto a fresh line before the prompt is drawn (mirrors zsh's PROMPT_SP).
printf '%*s\r' "$((${COLUMNS:-80} - 1))" ''

local LEFT_PROMPT=""
local SEGMENTS_AT_LEFT=0
local LAST_SEGMENT_COLOR=""
Expand Down
Loading