Closed qouoq closed 9 months ago
I can reproduce this with some random diff so it should be possible to create a test case for this. I will look into it as soon as I find the time.
Others are welcome to jump at this issue if you want to help.
I assume the origin of the bug is 21453a92506eb7dd75fa40e4db3a3afdc665636d
It seems that during startup ( with nvimpager -p - < diff-file -c 'set ft'
) the filetype is still diff
but later in the running nvim interface set ft
returns man
.
I have trouble writing a test case for this because I can not get the value from the running nvim process after it stated and opened the interface. Any ideas?
Interestingly, the diff-file I create reports man
, while test/fixtures/diff reports diff
.
I don't know if that can be used in the test framework (at least non-invasively), but if I add in the main nvimpager
bash script two commands in the args2
array, such as:
args2=(
--cmd 'lua nvimpager.stage1()'
-c 'lua nvimpager.stage2()'
-c 'echo &filetype'
-c 'qa'
)
Then I get:
$ ./nvimpager -c -- --clean diff-file
man%
$ ./nvimpager -c -- --clean test/fixtures/diff
diff%
@qouoq thank you that was a good hint, I was able to construct a test case that fails (locally at last, CI is currently broken for other reasons).
When viewing a diff with nvimpager, the file type detected is man. I see the behavior with 0.12.0 and with the main branch.
To try to make the test isolated, I proceed as follows:
hg diff > test_diff
(git diff
gives the same results)nvimpager -- --clean test_diff
:set filetype
reports mannvim --clean test_diff
:set filetype
reports diffPiping (
hg diff | nvimpager -- --clean
andhg diff | nvim --clean
) gives the same results for both nvimpager and neovim.I renamed
~/.config/nvimpager/init.vim
to make sure it's not interfering, but the--clean
option is sufficient to ignore it from what I see.Other files (for example markdown and lua from their extension, a bash script from its shebang) have their filetype detected by nvimpager as expected.
-- edit: I was thinking that might be related to some changes related to man page detection in v0.12.0, and indeed, v0.11.0 detects diffs as expected.