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

don't attempt to read file paths unless they are actually files. #205

Merged
merged 1 commit into from
May 15, 2015

Conversation

pleasetrythisathome
Copy link
Contributor

Fixes instances where cljx files have the same name as directories in the classpath.

@cichli
Copy link
Member

cichli commented May 11, 2015

LGTM, but please will you capitalise the commit message and remove the period at the end? :-)

@pleasetrythisathome
Copy link
Contributor Author

np

@@ -87,7 +87,7 @@
(when (= "file" (.getProtocol rsrc))
(io/as-file rsrc))
(io/as-file filename))]
(when (and file (.exists file))
(when (and file (.exists file) (.isFile file))
Copy link
Member

Choose a reason for hiding this comment

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

What problem did you run in to with the existing code?

If file isn't a File then the order of the statements in the and should be re-ordered or you risk running .exists on a String or whatever else file might be.

Copy link
Member

Choose a reason for hiding this comment

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

@expez a File can represent either a file or a directory, and if it's a directory, the following call to io/input-stream will throw.

@pleasetrythisathome just to clarify, you have a directory on the classpath whose name is something like core.cljs, and find-cljx-source is trying to open that instead of the actual core.cljs?

@pleasetrythisathome
Copy link
Contributor Author

@cichli yes that's exactly what i have. I often structure application where i have a fix like src/project/user.cljx and a directory src/project/user where i put implementation code for user.cljx.

@expez I believe file in the when predicate can only ever be nil (there is no resource matching filename), or a java.io.File, which could either be a file or a directory, and in the directory case, io/input-stream will throw as @cichli said

bbatsov added a commit that referenced this pull request May 15, 2015
don't attempt to read file paths unless they are actually files.
@bbatsov bbatsov merged commit 11152ee into clojure-emacs:master May 15, 2015
@bbatsov
Copy link
Member

bbatsov commented May 15, 2015

👍

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.

None yet

4 participants