Skip to content

Unsetting $fish_emoji_width doesn't clear the cached width #8274

Closed

Description

@lilyball

Latest fish master (3.3.1-288-g139b74d8e)

Setting $fish_emoji_width overrides the guessed emoji width. This override is cached globally. Unsetting it does not clear the cache.

> string length -V \U0001F44D
2
> set fish_emoji_width 1
> string length -V \U0001F44D
1
> set -e fish_emoji_width
> string length -V \U0001F44D
1

Another effect of this bug is that changing the variable in a local scope poisons the cache for the outer scope:

> string length -V \U0001F44D
2
> begin; set -l fish_emoji_width 1; string length -V string length -V \U0001F44D; end
1
> set -S fish_emoji_width
> string length -V \U0001F44D
1

It looks like I can set fish_emoji_width to 0 and this will cause fish to fall back to using the cached emoji guess (assuming it already guessed at emoji prior to setting the variable). So the workaround here looks like set fish_emoji_width 1; set -e fish_emoji_width in order to clear the cached width and then clear the variable.

Activity

  1. modified the milestones: fish 3.4.0, fish-future on Sep 7, 2021
  2. faho commented on Sep 7, 2021

    @faho
    Member

    Yeah, sure. For those reading along at home:

    $fish_emoji_width does not specify how wide all emoji are. It only tells us how to treat characters (mostly emoji) that were widened in unicode 9. A width of 2 is the post unicode 9 setting, 1 before.

    It's only a compatibility measure for outdated terminals/libcs, and should after detection rarely need to be set. If your libc says one of these is 2 wide, then you most likely also have a terminal new enough that (even if it has its own width table) it should use 2.

    This isn't a matter of preference, 2 is the correct value. (could the variable have been named better? Yeah)

  3. modified the milestones: fish-future, fish 3.4.0 on Sep 23, 2021
  4. added a commit that references this issue on Dec 12, 2021
  5. locked as resolved and limited conversation to collaborators on Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions