Skip to content

Commit

Permalink
fix(tmp buf): Detect shebang
Browse files Browse the repository at this point in the history
The `put = getbufline(<bufnr>, 1, '$')` copies lines with preserving
existing lines, so the destination buffer will still have a first empty
line and a shebang (e.g. `#!/bin/sh`) -- that tells which interpreter
of script file -- will be in second line and invalid. Duo to that,
filetype detection misses the shebang and doesn't work correctly. So move
it from the second line to the first by deleting a first empty line.
  • Loading branch information
alker0 committed Feb 28, 2023
1 parent c22e0ab commit 53e00f7
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions autoload/chezmoi/filetype.vim
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function! s:run_default_detect(detect_target) abort

" Copy contents from original buffer.
silent put = getbufline(bufnr_org, 1, '$')
silent 1delete

set eventignore=FileType,Syntax
execute 'doau filetypedetect BufRead ' . fnameescape(a:detect_target)
Expand Down

0 comments on commit 53e00f7

Please sign in to comment.