neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 0861ea6949a0c7281c56083092d389cae5d7bde8
parent 16e6f6e5841dd582620307e110b3da851e0e0a95
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sun, 23 Feb 2025 17:06:54 +0800

vim-patch:9.1.1139: [fifo] is not displayed when editing a fifo

Problem:  [fifo] is not displayed when editing a fifo
          (after v7.4.2189)
Solution: stat the filename and detect the type correctly

fixes: vim/vim#16702
closes: vim/vim#16705

https://github.com/vim/vim/commit/f1c3134ee1f263e537212a3072e8aa4cb7e8d953

Co-authored-by: Christian Brabandt <cb@256bit.org>

Diffstat:
Msrc/nvim/buffer.c | 2++
Msrc/nvim/fileio.c | 4+++-
Mtest/old/testdir/test_startup_utf8.vim | 28++++++++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c @@ -305,6 +305,8 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg) if (read_fifo) { curbuf->b_p_bin = save_bin; if (retval == OK) { + // don't add READ_FIFO here, otherwise we won't be able to + // detect the encoding retval = read_buffer(false, eap, flags); } } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c @@ -353,10 +353,11 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, } } - if (!read_buffer && !read_stdin && !read_fifo) { + if (!read_stdin && fname != NULL) { perm = os_getperm(fname); // On Unix it is possible to read a directory, so we have to // check for it before os_open(). + } #ifdef OPEN_CHR_FILES # define IS_CHR_DEV(perm, fname) S_ISCHR(perm) && is_dev_fd_file(fname) @@ -364,6 +365,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip, # define IS_CHR_DEV(perm, fname) false #endif + if (!read_stdin && !read_buffer && !read_fifo) { if (perm >= 0 && !S_ISREG(perm) // not a regular file ... && !S_ISFIFO(perm) // ... or fifo && !S_ISSOCK(perm) // ... or socket diff --git a/test/old/testdir/test_startup_utf8.vim b/test/old/testdir/test_startup_utf8.vim @@ -60,6 +60,34 @@ func Test_read_fifo_utf8() call delete('Xtestout') endfunc +func Test_detect_fifo() + CheckUnix + " Using bash/zsh's process substitution. + if executable('bash') + set shell=bash + elseif executable('zsh') + set shell=zsh + else + throw 'Skipped: bash or zsh is required' + endif + let linesin = ['one', 'two'] + call writefile(linesin, 'Xtestin_fifo', 'D') + let after = [ + \ 'call writefile(split(execute(":mess"), "\\n"), "Xtestout")', + \ 'quit!', + \ ] + " if RunVim([], after, '<(cat Xtestin_fifo)') + if RunVim(['set shortmess-=F'], after, '<(cat Xtestin_fifo)') + let lines = readfile('Xtestout') + call assert_match('\[fifo\]', lines[0]) + " call assert_match('\[fifo\]', lines[1]) + else + call assert_equal('', 'RunVim failed.') + endif + + call delete('Xtestout') +endfunc + func Test_detect_ambiwidth() CheckRunVimInTerminal