diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-15 17:07:42 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-03-10 10:58:58 +0200 |
| commit | f8be23b266aec7108fb4b80410623cd50ba8ded9 (patch) | |
| tree | a13b01e245b0ab86f0f0aac0163f911750dc08b0 /projectile.el | |
| parent | 659eda8ee7159f70ceef278060e9acd52ed01c6a (diff) | |
Disambiguate process buffer names for same-named projects
Fixes #1815
Fixes #1715
When two projects share the same name (e.g. both named "src"),
projectile-generate-process-name now detects the collision and
falls back to using the abbreviated project path in the buffer
name instead of just the project name.
Diffstat (limited to 'projectile.el')
| -rw-r--r-- | projectile.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/projectile.el b/projectile.el index 0936421..0584f66 100644 --- a/projectile.el +++ b/projectile.el @@ -1020,7 +1020,17 @@ just return nil." The function operates on the current project by default, but you can also specify a project explicitly via the optional PROJECT param." (let* ((project (or project (projectile-acquire-root))) - (base-name (format "*%s %s*" process (projectile-project-name project)))) + (name (projectile-project-name project)) + (base-name (format "*%s %s*" process name)) + ;; When a buffer with the same name already exists but belongs to a + ;; different project root, disambiguate using the project path. + (base-name (if (and (not make-new) + (let ((buf (get-buffer base-name))) + (and buf + (not (string= (with-current-buffer buf default-directory) + project))))) + (format "*%s %s*" process (abbreviate-file-name project)) + base-name))) (if make-new (generate-new-buffer-name base-name) base-name))) |
