macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.53k stars 685 forks source link

Conceal not working when printing in mac OS #1213

Closed countofsanfrancisco closed 3 years ago

countofsanfrancisco commented 3 years ago

Instructions: I have ConcealConsole set to nv and Conceallevel set to 3. I believe these are the defaults. I use AnsiEsc from https://www.vim.org/scripts/script.php?script_id=302.

Describe the bug When I enable AnsiEsc for an ANSI file with ANSI color encoding, the vim GUI displays it perfectly!! The escape sequence do not get shown and they are properly colorized. However, when I go to print it, the escape sequence is not concealed but the text is colored correctly according to the escape sequence. It just looks like the actual escape sequences are still printed. I am not sure how I can conceal the actual escape sequences. I tried looking for this in the help and even did a little bit of web searching but nothing seem obvious.

To Reproduce

  1. Produce a text file with ANSI escape sequences to show character colors, bold, underline, etc...
  2. Open that file up in vim after installing the aforementioned plugin.
  3. Enable the plugin using ":AnsiEsc" command.
  4. File --> print.

Notice how the preview shows the escape characters but yet the text are colored or emphasized correctly based on those escape sequences.

Expected behavior The escape sequences should not be shown since the text is appropriately colorized or emphasized by those escape sequences.

Screenshots image

Notice how in the screenshot of the PDF (when I do a vim file->print), that the escape sequence is still there but the word "Deprecated" is green.

Environment (please complete the following information):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug 30 2021 06:51:40)
macOS version
Included patches: 1-2029
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
-arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      -mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        -termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
-balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            -gettext           +netbeans_intg     +termresponse
+builtin_terms     -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           -ipv6              -perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     -keymap            +postscript        -vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      -langmap           -profile           +virtualedit
+comments          +libcall           +python/dyn        +visual
-conceal           +linebreak         -python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          -rightleft         +wildignore
+cursorshape       -lua               +ruby/dyn          +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
-emacs_tags        -mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      -mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa           

The terminal is the default MacOS terminal. MacOS version 11.6.

Additional context I am not sure if this is a plugin problem or a generic vim or a macvim problem or something else.

eirnym commented 3 years ago

Hi,

beside printing, I strongly recommend to try with version from 2020 instead from 2010 first. Even since 2020 vim got a lot of updates. Nevertheless, version from 2020 have higher chances to work more correctly.

countofsanfrancisco commented 3 years ago

I just used the latest official release and the same problem still occurs. By the way, the version I was using prior was 2019 (not 2010) according to "vim --help" (which I pasted originally). Anyways, I still upgraded to the latest that I found today on this github. Just for clarity, here is a snapshot of my gvim version:

image

eirnym commented 3 years ago

Do you have an access to a Linux and/or Windows machine to compare results?

Here I want to establish where to look for a root cause, in Vim core or MacVim UI

countofsanfrancisco commented 3 years ago

I tried this on a Windows VM with the latest vim. The problem occurs with Windows too. So, I presume then that I need to file this as an issue against the main vim (i.e. vim.org)? Or will macvim folks report it to them?

ychin commented 3 years ago

I think before you file the bug, you should probably try to make sure this is a Vim bug. The script you are using is quite old and currently unmaintained, so I'm more inclined to believe it's a bug with it.

As of the filing of this bug, I'm not really sure what bug it's supposed to be. Are you saying that the core "conceal" functionality in Vim is not working? It's totally possible that the plugin didn't properly conceal the escape sequence after applying highlight to the text. Edit: nevermind, see comments later.

ychin commented 3 years ago

But yes otherwise you should file the bug at Vim yourself (https://github.com/vim/vim/issues).

ychin commented 3 years ago

Oh wait actually, the bug is on using print itself (in Vim terminology it's hardcopy). I'm not sure if this is a bug, but this is just how Vim printing works. as it's not going to reproduce 1-to-1 what you see on screen unfortunately. There's actually a long thread (https://github.com/vim/vim/issues/4099) on how printing doesn't respect folded lines, but it's a somewhat different problem than this. Feel free to open an issue to discuss this on Vim.

For now, I think you could use :TOHtml which would convert your page to an HTML page which you can print out, and I think that should respect more visual aspects like conceal and folds.

Meanwhile I'm going to close this as this isn't MacVim related.