preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.12k stars 486 forks source link

Tagbar crash when parsing some utf8 files #748

Closed vds2212 closed 3 years ago

vds2212 commented 3 years ago

When tagbar is active and I open my _vimrc files that contains some utf8 characters tagbar crash.

To solve the problem I replace the following lines of tagbar\autoload\tagbar.vim:3054

    let l:pc = 0
    exec pyx . 'import subprocess, vim'
    exec pyx . '__argv = {"args":vim.eval("a:cmd"), "shell":True}'
    exec pyx . '__argv["stdout"] = subprocess.PIPE'
    exec pyx . '__argv["stderr"] = subprocess.STDOUT'
    exec pyx . '__pp = subprocess.Popen(**__argv, universal_newlines=True)'
    exec pyx . '__return_text = __pp.stdout.read()'
    exec pyx . '__pp.stdout.close()'
    exec pyx . '__return_code = __pp.wait()'
    exec 'let l:hr = '. python_eval .'("__return_text")'
    exec 'let l:pc = '. python_eval .'("__return_code")'

by:

    let l:pc = 0
    exec pyx . 'import subprocess, vim'
    exec pyx . '__argv = {"args":vim.eval("a:cmd"), "shell":True}'
    exec pyx . '__argv["stdout"] = subprocess.PIPE'
    exec pyx . '__argv["stderr"] = subprocess.STDOUT'
    exec pyx . '__pp = subprocess.Popen(**__argv, universal_newlines=True, encoding="utf8")'
    exec pyx . '__return_text = __pp.stdout.read()'
    exec pyx . '__pp.stdout.close()'
    exec pyx . '__return_code = __pp.wait()'
    exec 'let l:hr = '. python_eval .'("__return_text")'
    exec 'let l:pc = '. python_eval .'("__return_code")'

or more precisely:

    exec pyx . '__pp = subprocess.Popen(**__argv, universal_newlines=True)'

by:

    exec pyx . '__pp = subprocess.Popen(**__argv, universal_newlines=True, encoding="utf8")'
raven42 commented 3 years ago

A pull request is welcome. Please feel free to submit a PR for this change.

vds2212 commented 3 years ago

Thanks I have created a pull request (#749) with my fix.

Shane-XB-Qian commented 3 years ago

745

Shane-XB-Qian commented 3 years ago

looks all those started from that system_call changed from system() to 'python call', maybe had side-effect still.. // perhaps need a option to keep original way.. or let it be.. fyi.