diff --git a/functions/_tide_item_character.fish b/functions/_tide_item_character.fish index 10bb324..1d76851 100644 --- a/functions/_tide_item_character.fish +++ b/functions/_tide_item_character.fish @@ -3,10 +3,12 @@ function _tide_item_character set -q add_prefix || echo -ns ' ' - test "$fish_key_bindings" = fish_default_key_bindings && echo -ns $tide_character_icon || + if test "$fish_key_bindings" = fish_default_key_bindings + test $_tide_status = 0 && echo -ns $tide_character_icon || echo -ns $tide_character_icon_failure + else switch $fish_bind_mode case insert - echo -ns $tide_character_icon + test $_tide_status = 0 && echo -ns $tide_character_icon || echo -ns $tide_character_icon_failure case default echo -ns $tide_character_vi_icon_default case replace replace_one @@ -14,4 +16,5 @@ function _tide_item_character case visual echo -ns $tide_character_vi_icon_visual end + end end diff --git a/functions/tide/configure/icons.fish b/functions/tide/configure/icons.fish index a687bed..380638a 100644 --- a/functions/tide/configure/icons.fish +++ b/functions/tide/configure/icons.fish @@ -1,6 +1,7 @@ tide_aws_icon  # Actual aws glyph is harder to see tide_bun_icon 󰳓 tide_character_icon ❯ +tide_character_icon_failure ❯ tide_character_vi_icon_default ❮ tide_character_vi_icon_replace ▶ tide_character_vi_icon_visual V diff --git a/tests/_tide_item_character.test.fish b/tests/_tide_item_character.test.fish new file mode 100644 index 0000000..8169c3c --- /dev/null +++ b/tests/_tide_item_character.test.fish @@ -0,0 +1,180 @@ +# RUN: %fish %s +_tide_parent_dirs + +function _character + set -lx _tide_status $status + set -lx _tide_pipestatus $pipestatus + _tide_decolor (_tide_item_character) +end + +set -lx tide_character_icon_failure ✘ + +# Check icons while fish_key_bindings is fish_default_key_bindings +set -lx fish_key_bindings fish_default_key_bindings + +true +_character # CHECK: ❯ + +false +_character # CHECK: ✘ + +true | false +_character # CHECK: ✘ + +true | true +_character # CHECK: ❯ + +false | true +_character # CHECK: ❯ + +false | false +_character # CHECK: ✘ + +# Check that not command works +not true | false +_character # CHECK: ❯ + +not false | true +_character # CHECK: ✘ + +# Check icons while fish_key_bindings isn't fish_default_key_bindings +set -lx fish_key_bindings something_else +# Check icons while fish_bind_mode is default +set -lx fish_bind_mode default + +true +_character # CHECK: ❮ + +false +_character # CHECK: ❮ + +true | false +_character # CHECK: ❮ + +true | true +_character # CHECK: ❮ + +false | true +_character # CHECK: ❮ + +false | false +_character # CHECK: ❮ + +# Check that not command works +not true | false +_character # CHECK: ❮ + +not false | true +_character # CHECK: ❮ + +# Check icons while fish_bind_mode is insert +set -lx fish_bind_mode insert + +true +_character # CHECK: ❯ + +false +_character # CHECK: ✘ + +true | false +_character # CHECK: ✘ + +true | true +_character # CHECK: ❯ + +false | true +_character # CHECK: ❯ + +false | false +_character # CHECK: ✘ + +# Check that not command works +not true | false +_character # CHECK: ❯ + +not false | true +_character # CHECK: ✘ + +# Check icons while fish_bind_mode is replace +set -lx fish_bind_mode replace + +true +_character # CHECK: ▶ + +false +_character # CHECK: ▶ + +true | false +_character # CHECK: ▶ + +true | true +_character # CHECK: ▶ + +false | true +_character # CHECK: ▶ + +false | false +_character # CHECK: ▶ + +# Check that not command works +not true | false +_character # CHECK: ▶ + +not false | true +_character # CHECK: ▶ + +# Check icons while fish_bind_mode is replace_one +set -lx fish_bind_mode replace_one + +true +_character # CHECK: ▶ + +false +_character # CHECK: ▶ + +true | false +_character # CHECK: ▶ + +true | true +_character # CHECK: ▶ + +false | true +_character # CHECK: ▶ + +false | false +_character # CHECK: ▶ + +# Check that not command works +not true | false +_character # CHECK: ▶ + +not false | true +_character # CHECK: ▶ + +# Check icons while fish_bind_mode is visual +set -lx fish_bind_mode visual + +true +_character # CHECK: V + +false +_character # CHECK: V + +true | false +_character # CHECK: V + +true | true +_character # CHECK: V + +false | true +_character # CHECK: V + +false | false +_character # CHECK: V + +# Check that not command works +not true | false +_character # CHECK: V + +not false | true +_character # CHECK: V