nvim-tree / nvim-web-devicons

lua `fork` of vim-web-devicons for neovim
MIT License
2.08k stars 184 forks source link

Tex icon affects following text (if not separated by a space) #46

Closed mrossinek closed 3 years ago

mrossinek commented 3 years ago

I would like to point out an issue which I encountered a few months ago and had raised in vim-dirvish. A few weeks ago I added some updates which lead me to believe that this is indeed an issue of nvim-web-devicons rather than vim-dirvish. Rather than duplicating everything, please refer to the last updates in this issue: https://github.com/justinmk/vim-dirvish/issues/204

mrossinek commented 3 years ago

I realize that the information should really also be here for documentation purposes. Thus, here is the example to reproduce the issue:

Try for example opening the following file:

Text before TeX character:
test ﭨ

Text after TeX character (with a separating space):
ﭨ test

Text after TeX character (withOUT a separating space):
ﭨtest

Here is a screenshot of the results: screenshot_1614188843

The editors are:

System: Linux 5.10.16-arch1-1 Neovim: NVIM v0.5.0-dev+1094-gd623400ca Vim: VIM - Vi IMproved 8.2; Included patches: 1-2489

kyazdani42 commented 3 years ago

Hi again, i can say again that the issue does not come from this plugin. Try using this and you'll see how the text icon and following text renders properly. I'm not sure what's the issue in your screenshot which shows 4 perfectly similar buffers :/

mrossinek commented 3 years ago

Hi! Thanks for the reply. I will check out your other project! Might be a while before I get to it thought as I am rather busy lately. I also just noticed the same issue as above for the svg icon... I was wondering whether it may be some "reverse text unicode char" which gets triggered when not properly considering the icon as double width. But I really am no expert on this...

kyazdani42 commented 3 years ago

unicode characters can be 2, 3 or 4 bytes long, usually you should print out the correct number of bytes or else it might do some unusual things. But vim/nvim should handle that by itself properly (it's just utf-8 after all), not sure if dirvish does some funky stuff with the output ^^

mrossinek commented 3 years ago

But since the examples I posted above reproduce the issue in plain vim/nvim, should I rather raise the issue there? That is completely independent of the dirvish..

kyazdani42 commented 3 years ago

I cannot reproduce this issue on linux, neovim latest build. Which neovim version do you have ?

mrossinek commented 3 years ago

I just did a fresh compilation and installation of Neovim's master branch. Copying the contents of the example in my first comment on this issue still produces the same problem. Here is the output of :version:

:version
NVIM v0.5.0-dev+1174-g9f5c8226b
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -D
MIN_LOG_LEVEL=1 -I/home/max/Installations/neovim/build/config -I/home/max/Installations/neovim/src -I/home/max/Installations/neovim/.deps/usr/include -I/usr/include -I/home/max/Installations/neovim/build/src/nvim/auto -I/home/max/Installations/neovim/build/include
Compiled by max@ArchThinkPad

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/max/.local/share/nvim"

Run :checkhealth for more info

Update: I also tested Vim again and the same issue there. Here is its version (Arch package, not from master):

:version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 09 2021 23:51:55)
Included patches: 1-2489
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               ++builtin_terms    +cmdline_info      +diff              -farsi             -hangul_input      +langmap           +mksession         +mouse_sgr         +num64             +profile           +signs             +tag_binary        +textobjects       +virtualedit       +writebackup
+arabic            +byte_offset       +comments          +digraphs          +file_in_path      +iconv             +libcall           +modify_fname      -mouse_sysmouse    +packages          +python/dyn        +smartindent       -tag_old_static    +textprop          +visual            +X11
+autocmd           +channel           +conceal           +dnd               +find_in_path      +insert_expand     +linebreak         +mouse             +mouse_urxvt       +path_extra        +python3/dyn       +sound             -tag_any_white     +timers            +visualextra       -xfontset
+autochdir         +cindent           +cryptv            -ebcdic            +float             +ipv6              +lispindent        +mouseshape        +mouse_xterm       +perl/dyn          +quickfix          +spell             +tcl/dyn           +title             +viminfo           +xim
-autoservername    +clientserver      +cscope            +emacs_tags        +folding           +job               +listcmds          +mouse_dec         +multi_byte        +persistent_undo   +reltime           +startuptime       +termguicolors     +toolbar           +vreplace          -xpm
+balloon_eval      +clipboard         +cursorbind        +eval              -footer            +jumplist          +localmap          +mouse_gpm         +multi_lang        +popupwin          +rightleft         +statusline        +terminal          +user_commands     +wildignore        +xsmp_interact
+balloon_eval_term +cmdline_compl     +cursorshape       +ex_extra          +fork()            +keymap            +lua/dyn           -mouse_jsbterm     -mzscheme          +postscript        +ruby/dyn          -sun_workshop      +terminfo          +vartabs           +wildmenu          +xterm_clipboard
+browse            +cmdline_hist      +dialog_con_gui    +extra_search      +gettext           +lambda            +menu              +mouse_netterm     +netbeans_intg     +printer           +scrollbind        +syntax            +termresponse      +vertsplit         +windows           -xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo
 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY
_SOURCE=1
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-
gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lcanberra -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.32/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.32/core_perl/CORE
 -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
mrossinek commented 3 years ago

I think the problem lies with my terminal emulator kitty... I am sorry for not having investigated this earlier. I just installed alacritty and it does not suffer from this issue. I will take my issue to kitty then :+1:

Sorry for the spamming and re-raising of this issue

jdrouhard commented 3 years ago

@kyazdani42 I did some investigation on this.

I don't think the problem is with terminal emulators. The issue is that some of the icons switch the active direction of text to RTL and affects the surrounding text. Unicode introduced direction isolates specifically to help with this issue.

I've verified that if the icon text is surrounded with LTR isolate markers, then the icons will no longer mess up the rendering of surrounding text if the terminal emulator properly applies the bidi algorithm (modern terminal emulators do). Isolates specifically do not affect the direction of the surrounding text so this won't affect rendering if the icon appears in RTL text.

Maybe the icons that use codepoints that are designated as RTL (Tex, SVG, etc) should have LTR isolate markers around the unicode codepoint. This would involve something like:

["tex"] = {
    icon = "<U+2066>ﭨ<U+2069>", -- actual utf-8 encoded codepoints instead, this is for demonstration
    color = "#3D6117",
    name = "Tex"
  };
...

Would you like me to open a new issue for this? What do you think?