@@ -8,6 +8,46 @@ function local_setup_file() {
88 load " ${BASH_IT?} /themes/powerline/powerline.base.bash"
99}
1010
11+ # Stub a no-op segment so we can run __powerline_prompt_command without
12+ # sourcing every plugin that the default segments depend on.
13+ function __powerline_noop_prompt() { : ; }
14+ # _save-and-reload-history is called unconditionally; stub it out.
15+ function _save-and-reload-history() { : ; }
16+
17+ # --- __powerline_prompt_command: missing-newline handler (fixes #2372) ---
18+
19+ @test " powerline base: __powerline_prompt_command overflows the line and returns to column 1" {
20+ COLUMNS=20
21+ POWERLINE_PROMPT=(" noop" )
22+ run __powerline_prompt_command
23+
24+ local expected
25+ expected=" $( printf ' %*s\r' " $(( COLUMNS - 1 )) " ' ' ) "
26+ assert_output --partial " ${expected} "
27+ }
28+
29+ @test " powerline base: __powerline_prompt_command missing-newline sequence is first output" {
30+ COLUMNS=20
31+ POWERLINE_PROMPT=(" noop" )
32+ run __powerline_prompt_command
33+
34+ # Confirm the padding+carriage-return appears at the very start, meaning it
35+ # is a direct printf rather than anything embedded in PS1 or segments.
36+ local prefix
37+ prefix=" $( printf ' %*s\r' " $(( COLUMNS - 1 )) " ' ' ) "
38+ [[ " ${output} " == " ${prefix} " * ]]
39+ }
40+
41+ @test " powerline base: __powerline_prompt_command falls back to 80 columns when COLUMNS is unset" {
42+ unset COLUMNS
43+ POWERLINE_PROMPT=(" noop" )
44+ run __powerline_prompt_command
45+
46+ local expected
47+ expected=" $( printf ' %*s\r' 79 ' ' ) "
48+ assert_output --partial " ${expected} "
49+ }
50+
1151function local_setup() {
1252 LEFT_PROMPT=" "
1353 SEGMENTS_AT_LEFT=0
0 commit comments