Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not error inside of projectile-cache-current-file when opening a file inside a project. #957

Merged

Conversation

jbenden
Copy link
Contributor

@jbenden jbenden commented Feb 1, 2016

When opening a file from the terminal, it is possible for the
file to be a project and have the switch-to-buffer hook run,
with a new buffer that has no associated file.

@bbatsov
Copy link
Owner

bbatsov commented Feb 3, 2016

I'm not quite certain what you mean. Some exact repro steps would be useful.

@jbenden
Copy link
Contributor Author

jbenden commented Feb 3, 2016

It's a nil condition with the line patched. Simple fix.

-Joe

@bbatsov
Copy link
Owner

bbatsov commented Feb 4, 2016

When I looked closer at the code I understood the problem, but the description of the commit and the changelog entry are misleading - in reality we simply don't want to attempt to cache a buffer which is not backed by a file.

@@ -657,7 +657,7 @@ The cache is created both in memory and on the hard drive."
"Add the currently visited file to the cache."
(interactive)
(let ((current-project (projectile-project-root)))
(when (gethash (projectile-project-root) projectile-projects-cache)
(when (and (gethash (projectile-project-root) projectile-projects-cache) (buffer-file-name (current-buffer)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move the file check before the cache check. Also (buffer-file-name (current-buffer)) can be replaced with simply buffer-file-name. No need for two function calls. I see the same was used a line below, which can be optimized.

@bbatsov
Copy link
Owner

bbatsov commented Feb 26, 2016

ping

jbenden added a commit to jbenden/projectile that referenced this pull request Mar 11, 2016
* Check buffer-file-name before cache entries.
* Add bug fix to CHANGELOG entries under bugs fixed.
jbenden added a commit to jbenden/projectile that referenced this pull request Mar 11, 2016
* buffer-file-name returns the current buffer when no
  argument is specified.
@bbatsov
Copy link
Owner

bbatsov commented Mar 17, 2016

There are two entries in the changelog now. Remove the old one, rebase on top of the current master and squash the commits into one.

@jbenden jbenden force-pushed the cache-current-file-has-no-file-assoc branch from 8b66289 to f0d4a4d Compare March 17, 2016 16:51
@jbenden
Copy link
Contributor Author

jbenden commented Mar 17, 2016

Please review rebase.

On Mar 16, 2016, at 10:43 PM, Bozhidar Batsov notifications@github.com wrote:

There are two entries in the changelog now. Remove the old one, rebase on top of the current master and squash the commits into one.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

@bbatsov
Copy link
Owner

bbatsov commented Mar 17, 2016

I still see two entries in the changelog and the branch is still outdated compared to the current upstream master.

When opening a file from the terminal, it is possible for the
file to be a project and have the `switch-to-buffer` hook run,
with a new buffer that has no associated file.
@jbenden jbenden force-pushed the cache-current-file-has-no-file-assoc branch from f0d4a4d to 2100025 Compare March 18, 2016 15:07
@jbenden
Copy link
Contributor Author

jbenden commented Mar 18, 2016

Sorry. Hopefully ok now.

Sent from my iPad

On Mar 17, 2016, at 12:09 PM, Bozhidar Batsov notifications@github.com wrote:

I still see two entries in the changelog and the branch is still outdated compared to the current upstream master.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

bbatsov added a commit that referenced this pull request Mar 18, 2016
…ssoc

Do not error inside of `projectile-cache-current-file` when opening a file inside a project
@bbatsov bbatsov merged commit d166251 into bbatsov:master Mar 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants