PsychoLlama / alternaut.vim

Jump between your test and source files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alternauting from test to source when they share the same directory hangs.

taylor1791 opened this issue · comments

I started a new job. Every "component" has a directory and everything related to that component is in that directory, including tests. Here is an example.

src/components/header/
├── styles.js
├── header.js
├── header.test.js
└── package.json

I added '.' to my directory_naming_conventions and continued on with my life. I alternauted from source to test and exclaimed, "NICE! This psycho llama thought of everything!" I toggled from the test to the source and neovim hung indefinitely, until I Ctrl+C-ed.

I might fix it, you might it; we just have to decide first. I consider this a severity-0 bug since it really messes up my flow, man...

Ah, bummer. I was hoping nobody used that pattern. IIRC I wrote alternaut to prefer folder structure over file extensions. This is the offending code:

" [truncated]
func! alternaut#is_test_file(file_path) abort
  let l:full_file_path = fnamemodify(a:file_path, ':p')
  let l:lang_definition = alternaut#config#load_conventions(&filetype)

  return alternaut#search#find_parent_test_directory(a:file_path, l:lang_definition) isnot# v:null
endfunc

None of your parent directories are in the directory_naming_conventions list verbatim, so I suspect alternaut thinks your test file is a source file and starts upward scanning your test directories...

findfile(l:test_file_name, l:test_file_directory . '/**')

Normally that looks like __tests__/**, but . kinda broadens the search 😆

I'll see about making that function aware of file extensions later tonight.

Alright @taylor1791 give it a whirl and lemme know if it works 👍

It works! 🙇

P.S. I like your hobby projects.