alt icon indicating copy to clipboard operation
alt copied to clipboard

Return file name even if it does not exists

Open charlax opened this issue 3 years ago • 3 comments

Let's say I'm in Vim, editing app/lib/hashing.py.

app/lib/hashing_test.py does not exist, but I'd like to work on the tests.

Yet this command returns nothing:

$ alt app/lib/hashing.py

I'd be expecting (provided there are some other tests in the repo):

$ alt app/lib/hashing.py
app/lib/hashing_test.py

charlax avatar Jul 06 '22 16:07 charlax

Right now it does not support this because of a fundamental design choice.

The alternate file determination isn't based on a standard schema for two main reasons.

  • across frameworks and languages the schemas conflict with each other (I originally created a vim plugin this way and ran into these issues https://github.com/uptech/vim-open-alternate)
  • even within the same framework they are NOT consistent in schema and can conflict with each other

Therefore to support all the different languages and frameworks I decided to not support the create empty alternate use case. But support all the different languages and frameworks by generically identifying alternate files based on similarity of naming of the paths and files which requires both files to exist to be able to match them and return the alternate.

I don't feel like there is a great approach to solve this use case and facilitate the general languages and frameworks use case. But I am always open to ideas.

drewdeponte avatar Jul 27 '22 14:07 drewdeponte

I feel like it would make sense to have a way to provide the schema explicitly rather than only relying on guessing it based on existing files. Wdyt?

charlax avatar Aug 18 '22 15:08 charlax

This could be done but I think it is a bit of a different tool. It would have to be a something that is configured maybe at a repository level. It would likely not work with mono repos with different testing strategies. Unless we make the configuration file not repo bound and it did some dir structure climbing to find the nearest config and used that.

But yes I think it would be possible technically to build something based on configuration.

This morning I was actually thinking maybe it would make sense for a separate thing to be run if it can't find an alternate. Maybe this would be this create from configured scheme thing. Maybe it is smart and can try and detect scheme and if it is capable of detecting the scheme then it doesn't need a configuration.

drewdeponte avatar Aug 19 '22 02:08 drewdeponte