SudoEdit.vim icon indicating copy to clipboard operation
SudoEdit.vim copied to clipboard

Read contents suddenly disappear

Open Gasol opened this issue 5 years ago • 5 comments

Here is screencast for demo. I also run vim without configuration (-u NORC), the result is remain the same.

SudoEdit

My environment

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:        16.04
Codename:       xenial

$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 02 2017 06:40:50)
Included patches: 1-134
Modified by pi-rho
Compiled by buildd@lcy01-12
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     +termguicolors
-browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
-clientserver    +insert_expand   +packages        -toolbar
-clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        +perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       +python/dyn      +vreplace
+cscope          +lispindent      +python3/dyn     +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      +lua/dyn         +rightleft       +writebackup
+diff            +menu            +ruby/dyn        -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xpm
+emacs_tags      -mouseshape      +startuptime     -xsmp
+eval            +mouse_dec       +statusline      -xterm_clipboard
+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax
+farsi           +mouse_netterm   +tag_binary
   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   -Wdate-time  -Wall -Wextra -g -O2 -fPIE -Wformat -Werror=format-security -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,-z,nodlopen -Wl,-z,nodump -Wl,-z,noexecstack -Wl,-z,noexecheap -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux   -lacl -lattr -lgpm -ldl   -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.22/CORE -lperl -ldl -lm -lpthread -lcrypt

My configuration for Vim https://github.com/Gasol/vimrc

Gasol avatar Dec 03 '19 04:12 Gasol

So what are the resulting 252 lines in the :mess output? Have you tried the command in the :mess output manually? It started with :verb 0read sudo .... (couldn't see more).

chrisbra avatar Dec 03 '19 07:12 chrisbra

So what are the resulting 252 lines in the :mess output? Have you tried the command in the :mess output manually? It started with :verb 0read sudo .... (couldn't see more).

It means the file I want to read is 252 lines in total, I was ran :SudoRead twice to generate :mess output as following, After that, I manually run verb :0r! sudo cat 'trac/demo/conf/trac.ini' in command mode, It works as I expected.

Messages maintainer: Bram Moolenaar <[email protected]>
Type  :quit<Enter>  to exit Vim
verb :0r! sudo  cat 'trac/demo/conf/trac.ini'
Error detected while processing function SudoEdit#SudoDo[17]..<SNR>124_SudoRead[16]..<SNR>124_Exec:
line    8:
W10: Warning: Changing a readonly file
Reading viminfo file "/home/gasolwu/.viminfo" marks
250 more lines
verb :0r! sudo  cat 'trac/demo/conf/trac.ini'
250 more lines
Press ENTER or type command to continue

Gasol avatar Dec 03 '19 08:12 Gasol

On Di, 03 Dez 2019, Gasol Wu wrote:

So what are the resulting 252 lines in the :mess output? Have you tried the command in the :mess output manually? It started with :verb 0read sudo .... (couldn't see more).

It means the file I want to read is 252 lines in total, I was ran :SudoRead twice to generate :mess output as following, After that, I manually run verb :0r! sudo cat 'trac/demo/conf/trac.ini' in command mode, It works as I expected.

Messages maintainer: Bram Moolenaar <[email protected]>
Type  :quit<Enter>  to exit Vim
verb :0r! sudo  cat 'trac/demo/conf/trac.ini'
Error detected while processing function SudoEdit#SudoDo[17]..<SNR>124_SudoRead[16]..<SNR>124_Exec:
line    8:
W10: Warning: Changing a readonly file
Reading viminfo file "/home/gasolwu/.viminfo" marks
250 more lines
verb :0r! sudo  cat 'trac/demo/conf/trac.ini'
250 more lines
Press ENTER or type command to continue

Not sure why it fails then. Can you then step manually through the :SudoEdit command and check where/why it fails?

Start by :debug :SudoEdit ...

You can use :n for next message, :s to step into a function, :redraw to redraw screen.

Thanks, Christian

Wer stets nur sich selbst finden will, kann leicht einen anderen verlieren. -- at

chrisbra avatar Dec 03 '19 08:12 chrisbra

Hope this will be helpful, thank you.

debug

Gasol avatar Dec 03 '19 08:12 Gasol

I can't see anything wrong. It is correct after SudoRead() when it redraws the screen. Later on, it should only delete the trailing last line :$d _. Just before executing it and you hit :q!, is the content still there?

Do you have any unusual configurations for sudo or the shell options? does that happen with any file?

what other scripts and plugins have you are running? If you start from the directory of where it is installed, does it work when starting vim like this: vim --clean --cmd ":set rtp+=$PWD" -c ':ru plugin/SudoEdit.vim'?

chrisbra avatar Dec 03 '19 11:12 chrisbra