In languages that have rich module systems, you’ll end up with the same filename reused across multiple directories. For example, in Rust every module might have a mod.rs
file. As another example, in Python every module will have an __init__.py
file. If you open more than one of these identically named files a time, it becomes ambiguous what tab corresponds to what file. As shown in the screenshot:
Maybe builder should disambiguate the filenames in some way? Here’s how VS Code handles it:
Possible solutions:
- Show project-relative full paths, so the tab title would be
/src/page/language/mod.rs
- Show the immediate parent directory. Doesn’t cover all usecases but is an easy solution that helps a lot of the time. So the tab title would be
language/mod.rs
- Have some algorithm to intelligently disambiguate based on the exact collection of tabs visible. This is VS Code’s behavior, so the exact algorithm to decide which chunks of path to show should be copied from them:
- If only
src/a/mod.rs
is open, then the tab title would bemod.rs
- If
src/a/mod.rs
andsrc/b/mod.rs
are shown then make the titlesa/mod.rs
andb/mod.rs
respectively - if
src/a/mod.rs
,src/b/mod.rs
, andsrc/some/subdir/a/mod.rs
are shown, then the titles would be/src/a/mod.rs
,b/mod.rs
, andsubdir/a/mod.rs
respectively
- If only
- In addition to one of the methods above, use the language server to resolve the actual name of the module relative to the root of the project, and use that as the tab title (so for example:
src/page/language/mod.rs
would instead be shown ascrate::page::language
, andsrc/page/language/filter.rs
would be shown ascrate::page::language::filter
)