dschwen / switch-header-source

Quick switching between C/C++ header and source files
MIT License
13 stars 49 forks source link

Plugin opens files from other projects #26

Open lczech opened 6 years ago

lczech commented 6 years ago

The configuration says

The plugin will match each file's name in the project...

but it opens files from other Project Folders, too. In my particular case, I am working on a library, but also have a project that uses the library as a git submodule. So, when invoking the plugin, it sometimes switches to the copy in the submodule...

dschwen commented 6 years ago

Excellent point. I don't see how anyone would need to switch to a header or source in a different project.

lczech commented 6 years ago

On that note, I also sometimes have trouble with files named the same, but in different directories. For example, foo.hpp header and foo.cpp implementation in on dir, and foo.cpp in the test dir. I tried changing the regex to start with ^, so that the whole directory is matched only, but that also just resulted in opening the file from the other project, as explained above.

Is there a way to tell the plugin to prefer opening files from the same dir?

Glandos commented 5 years ago

Is there a way to tell the plugin to prefer opening files from the same dir?

I see a problem in the switchMap design.

Currently, the switchMap is built with basename as key, and a list of full paths as value. In this list, files can be found in multiple projects, and they can even have the same name (not only basename, e.g. ["src/Class.h", "tst/Class.h"]), resulting in a weird source switching.

This map should index things differently to solve different pending issues. Let's start with one thought:

This is a start, and a call for ideas. Maybe the full path should be used in the key? Of course, the map will use more memory… But we don't need a light-but-buggy packages :smile: