From 04166dd211667c1bf67969ba96004aa91279d38d Mon Sep 17 00:00:00 2001 From: MarcoVeio Date: Sun, 4 Feb 2024 02:13:34 -0300 Subject: [PATCH 1/3] adding a new icon for character when there's a failure --- functions/_tide_item_character.fish | 7 ++++-- functions/tide/configure/icons.fish | 1 + tests/_tide_item_character.test.fish | 35 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/_tide_item_character.test.fish diff --git a/functions/_tide_item_character.fish b/functions/_tide_item_character.fish index 10bb324..736bc6a 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 70611cd..73181ac 100644 --- a/functions/tide/configure/icons.fish +++ b/functions/tide/configure/icons.fish @@ -1,5 +1,6 @@ tide_aws_icon  # Actual aws glyph is harder to see 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..62e6c0d --- /dev/null +++ b/tests/_tide_item_character.test.fish @@ -0,0 +1,35 @@ +# 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 ✘ + +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: ✘ From 9f71d80a7ea415935ccdabcb2962094f08bd93f1 Mon Sep 17 00:00:00 2001 From: MarcoVeio Date: Sun, 4 Feb 2024 02:51:55 -0300 Subject: [PATCH 2/3] fixing fish key bindings test --- functions/_tide_item_character.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/_tide_item_character.fish b/functions/_tide_item_character.fish index 736bc6a..1d76851 100644 --- a/functions/_tide_item_character.fish +++ b/functions/_tide_item_character.fish @@ -3,7 +3,7 @@ function _tide_item_character set -q add_prefix || echo -ns ' ' - if test $fish_key_bindings = fish_default_key_bindings + 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 From f35461a077861b28b35fd9295a00ba355f6d8780 Mon Sep 17 00:00:00 2001 From: MarcoVeio Date: Sun, 4 Feb 2024 03:16:05 -0300 Subject: [PATCH 3/3] testing character with different fish_key_bindings and fish_bind_mode --- tests/_tide_item_character.test.fish | 145 +++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/tests/_tide_item_character.test.fish b/tests/_tide_item_character.test.fish index 62e6c0d..8169c3c 100644 --- a/tests/_tide_item_character.test.fish +++ b/tests/_tide_item_character.test.fish @@ -9,6 +9,9 @@ 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: ❯ @@ -33,3 +36,145 @@ _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