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
32 changes: 32 additions & 0 deletions test/themes/powerline.base.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# shellcheck shell=bats
# shellcheck disable=SC2034 # Variables consumed by externally-loaded powerline functions.

load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup_file() {
setup_libs "colors"
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 outputs missing-newline escape sequence to stdout" {
POWERLINE_PROMPT=("noop")
run __powerline_prompt_command
assert_output --partial $'\e[7m%\e[0m\r\e[K'
}

@test "powerline base: __powerline_prompt_command missing-newline sequence is first output" {
POWERLINE_PROMPT=("noop")
run __powerline_prompt_command
# Use bash pattern match to confirm the sequence appears at the very start,
# meaning it is a direct printf rather than anything embedded in PS1 or segments.
local prefix=$'\e[7m%\e[0m\r\e[K'
[[ "${output}" == "${prefix}"* ]]
}
4 changes: 4 additions & 0 deletions themes/powerline/powerline.base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ function __powerline_prompt_command() {
local beginning_of_line='\[\e[G\]'
local info prompt_color segment prompt

# Reversed % marks where a missing trailing newline was; \r\e[K then
# clears the line so the prompt always starts cleanly at column 1.
printf '%b' '\e[7m%\e[0m\r\e[K'

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