Skip to content

Commit

Permalink
Improve ftdetect regex and fix test runner stall when there are more …
Browse files Browse the repository at this point in the history
…than 7 tests
  • Loading branch information
laniakea64 committed Dec 2, 2023
1 parent 9f479d9 commit 31a72a2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ftdetect/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
" URL: https://github.com/NoahTheDuke/vim-just.git
" Last Change: 2021 Aug 26
au BufNewFile,BufRead \cjustfile,.justfile,*.just setfiletype just
au BufNewFile,BufRead * if getline(1) =~# '\v^#!/%(\w|[/-])*\w/%(env%(\s+-S)?\s+)?just' | setfiletype just | endif
au BufNewFile,BufRead * if getline(1) =~# '\v^#!//@!%(\w|-|//@!)*/%(env%(\s+-S)?\s+)?just\A' | setfiletype just | endif
6 changes: 6 additions & 0 deletions tests/batch_ftdetect_res.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
" Disable pager
set nomore

bufdo redir >> $OUTPUT | echo @% | set ft? | redir END

" Prevent stalling on 'Press ENTER or type command to continue'
call feedkeys("\<CR>")

qa
19 changes: 19 additions & 0 deletions tests/cases/ftdetect.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,27 @@
{
"content": "#!/usr/local/bin/just -f\n"
},
{
"content": "#!/opt/local/bin-/just -f\n"
},
{
"content": "",
"not_justfile": true
},
{
"content": "#!/usr/bin/just",
"not_justfile": true
},
{
"content": "#!/usr/bin/just\n",
"not_justfile": true
},
{
"content": "#!/usr//bin/env just -f\n",
"not_justfile": true
},
{
"content": "#!//usr/local/bin/just -f\n",
"not_justfile": true
}
]
2 changes: 1 addition & 1 deletion tests/src/test-ftdetect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn _main() -> io::Result<()> {
let ftdetect_results = tempdir.path().join("ftdetect_results.txt");

let mut vim = Command::new("vim")
.args(["--not-a-term", "-S", "batch_ftdetect_res.vim"])
.args(["--not-a-term", "-R", "-S", "batch_ftdetect_res.vim"])
.args(file2case.keys())
.env("OUTPUT", &ftdetect_results)
.env("HOME", env::current_dir().unwrap())
Expand Down

0 comments on commit 31a72a2

Please sign in to comment.