diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cb3ee33..906e41f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -26,9 +26,11 @@ jobs: with: plugins: ilancosman/clownfish $GITHUB_WORKSPACE + - run: fish $GITHUB_WORKSPACE/tests/test_setup.fish + - uses: fish-actions/littlecheck@v1 with: - files: $GITHUB_WORKSPACE/tests/** + files: $GITHUB_WORKSPACE/tests/**.test.fish syntax-check: runs-on: ubuntu-latest diff --git a/functions/_tide_prompt.fish b/functions/_tide_prompt.fish index e4b7883..c5277d3 100644 --- a/functions/_tide_prompt.fish +++ b/functions/_tide_prompt.fish @@ -4,7 +4,7 @@ function _tide_prompt test "$tide_prompt_add_newline_before" = true && echo - left_prompt=(_tide_left_prompt) right_prompt=(_tide_right_prompt) if set -q left_prompt[2] # If the prompt is two lines + left_prompt=(_tide_left_prompt) right_prompt=(_tide_right_prompt) if set -q left_prompt[2] # If prompt is two lines set -l prompt_and_frame_color (set_color $tide_prompt_frame_and_connection_color -b normal || echo) if test "$tide_left_prompt_frame_enabled" = true @@ -18,7 +18,8 @@ function _tide_prompt printf '%s' $left_prompt[1] $prompt_and_frame_color - set -l length_to_move (math $COLUMNS - (_tide_decolor "$left_prompt[1]""$right_prompt[1]" | string length)) + set -l length_to_move (math $COLUMNS - ( # Regex removes color codes + string replace -ar '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$left_prompt[1]""$right_prompt[1]" | string length)) test $length_to_move -gt 0 && string repeat --no-newline --max $length_to_move $tide_prompt_connection_icon printf '%s' $right_prompt[1] \n $left_prompt[-1]' ' diff --git a/tests/_tide_decolor.test.fish b/tests/_tide_decolor.test.fish deleted file mode 100644 index 8e11070..0000000 --- a/tests/_tide_decolor.test.fish +++ /dev/null @@ -1,9 +0,0 @@ -# RUN: %fish %s - -function _decolor -a color - _tide_decolor (set_color $color || echo)'Hello Foo' -end - -_decolor red # CHECK: Hello Foo -_decolor normal # CHECK: Hello Foo -_decolor D7AF00 # CHECK: Hello Foo diff --git a/functions/_tide_decolor.fish b/tests/test_setup.fish similarity index 80% rename from functions/_tide_decolor.fish rename to tests/test_setup.fish index cf7390e..df9f2e1 100644 --- a/functions/_tide_decolor.fish +++ b/tests/test_setup.fish @@ -1,3 +1,5 @@ function _tide_decolor string replace --all --regex '\e(\[[\d;]*|\(B\e\[)m(\co)?' '' "$argv" end + +funcsave _tide_decolor