fix root in cp-find-file / cp-switch-to-buffer
For some reason, when one of these two functions was used as an action in cp-switch-project, its actions were losing track of the project root against which to expand filenames (they were using the root of the root of the project from which cp-switch-project was called instead of the root of the selected project to switch to). To fix this issue, the correct root is now recorded in the candidate files / buffers.
This commit is contained in:
parent
b157a8d12c
commit
e5f2f20a16
1 changed files with 14 additions and 8 deletions
|
|
@ -71,9 +71,12 @@ With a prefix ARG invalidates the cache first."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(projectile-maybe-invalidate-cache arg)
|
(projectile-maybe-invalidate-cache arg)
|
||||||
(ivy-read (projectile-prepend-project-name "Find file: ")
|
(ivy-read (projectile-prepend-project-name "Find file: ")
|
||||||
(projectile-current-project-files)
|
(let ((root (projectile-project-root)))
|
||||||
|
(mapcar (lambda (name)
|
||||||
|
(cons name (expand-file-name name root)))
|
||||||
|
(projectile-current-project-files)))
|
||||||
:action (lambda (x)
|
:action (lambda (x)
|
||||||
(find-file (projectile-expand-root x)))
|
(find-file (cdr x)))
|
||||||
:require-match t
|
:require-match t
|
||||||
:keymap counsel-projectile-map
|
:keymap counsel-projectile-map
|
||||||
:caller 'counsel-projectile-find-file)
|
:caller 'counsel-projectile-find-file)
|
||||||
|
|
@ -82,7 +85,7 @@ With a prefix ARG invalidates the cache first."
|
||||||
(ivy-set-actions
|
(ivy-set-actions
|
||||||
'counsel-projectile-find-file
|
'counsel-projectile-find-file
|
||||||
'(("j" (lambda (x)
|
'(("j" (lambda (x)
|
||||||
(find-file-other-window (projectile-expand-root x)))
|
(find-file-other-window (cdr x)))
|
||||||
"other window")))
|
"other window")))
|
||||||
|
|
||||||
;;; counsel-projectile-find-dir
|
;;; counsel-projectile-find-dir
|
||||||
|
|
@ -95,11 +98,14 @@ With a prefix ARG invalidates the cache first."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(projectile-maybe-invalidate-cache arg)
|
(projectile-maybe-invalidate-cache arg)
|
||||||
(ivy-read (projectile-prepend-project-name "Find dir: ")
|
(ivy-read (projectile-prepend-project-name "Find dir: ")
|
||||||
|
(let ((root (projectile-project-root)))
|
||||||
|
(mapcar (lambda (name)
|
||||||
|
(cons name (expand-file-name name root)))
|
||||||
(if projectile-find-dir-includes-top-level
|
(if projectile-find-dir-includes-top-level
|
||||||
(append '("./") (projectile-current-project-dirs))
|
(append '("./") (projectile-current-project-dirs))
|
||||||
(projectile-current-project-dirs))
|
(projectile-current-project-dirs))))
|
||||||
:action (lambda (x)
|
:action (lambda (x)
|
||||||
(dired (projectile-expand-root x)))
|
(dired (cdr x)))
|
||||||
:require-match t
|
:require-match t
|
||||||
:keymap counsel-projectile-map
|
:keymap counsel-projectile-map
|
||||||
:caller 'counsel-projectile-find-dir)
|
:caller 'counsel-projectile-find-dir)
|
||||||
|
|
@ -108,7 +114,7 @@ With a prefix ARG invalidates the cache first."
|
||||||
(ivy-set-actions
|
(ivy-set-actions
|
||||||
'counsel-projectile-find-dir
|
'counsel-projectile-find-dir
|
||||||
'(("j" (lambda (x)
|
'(("j" (lambda (x)
|
||||||
(dired-other-window (projectile-expand-root x)))
|
(dired-other-window (cdr x)))
|
||||||
"other window")))
|
"other window")))
|
||||||
|
|
||||||
;;; counsel-projectile-switch-to-buffer
|
;;; counsel-projectile-switch-to-buffer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue