SublimeText / RSpec

Sublime Text 2 / 3 plugin for RSpec BDD Framework
124 stars 57 forks source link

Shortcut opening wrong file #51

Closed victoryftw closed 9 years ago

victoryftw commented 9 years ago

I'm encountering an issue where using the ctrl/command + . shortcut doesn't open the correct file. Specifically, I have the following files:

lib/c/process.rb lib/c/process_spec.rb lib/u/process.rb lib/u/process_spec.rb

The command works fine for switching back and forth between c/process.rb and c/process_spec.rb, but when I attempt to switch from u/process.rb to u/process_spec.rb, the command opens c/process_spec.rb instead. The same is true in reverse; u/process_spec.rb opens c/process.rb.

I can recreate this issue with several different sets of files in my codebase, and it appears to take the file that is in the parent directory (or maybe the module) which is alphabetically first.

This bug is particularly bothersome because its not always immediately obvious which file was opened, since the files have the same name. Let me know if more information would be helpful in recreating the issue.

princemaple commented 9 years ago

Hi @victoryftw could I have your ST version? Also, I should have fixed this issue recently, could you make sure you have the latest version of the plugin installed?

Thanks

princemaple commented 9 years ago

btw, did you mean you have

lib/c/process.rb
spec/c/process_spec.rb
lib/u/process.rb
spec/u/process_spec.rb

?

princemaple commented 9 years ago

You probably did have your specs in your lib directory? That's not what the convention is like. This gif shows how it correctly switches between the code and the spec. screenshot

princemaple commented 9 years ago

FYI, the command falls back to alphabetically searching the whole project folder when failing to find the according file by convention. That's why you are encountering this behavior.

victoryftw commented 9 years ago

Sorry that I omitted the /spec directory, my files are organized as such (which I see is slightly different from the convention gif you posted):

lib/c/process.rb spec/lib/c/process_spec.rb lib/u/process.rb spec/lib/u/process_spec.rb

Which would appear to be the cause of the issue, if the fall-back is to search alphabetically. Perhaps it should fall-back to searching for the path in /spec first? Either way, you're right that it is performing as intended.

princemaple commented 9 years ago

I'll work on a fix soon. I have an idea now, thanks for reporting!

On Tue, 25 Nov 2014 17:33 Jake Epstein notifications@github.com wrote:

Sorry that I omitted the /spec directory, my files are organized as such (which I see is slightly different from the convention gif you posted):

lib/c/process.rb spec/lib/c/process_spec.rb lib/u/process.rb spec/lib/u/process_spec.rb

Which would appear to be the cause of the issue, if the fall-back is to search alphabetically. Perhaps it should fall-back to searching for the path in /spec first? Either way, you're right that it is performing as intended.

— Reply to this email directly or view it on GitHub https://github.com/SublimeText/RSpec/issues/51#issuecomment-64316397.

princemaple commented 9 years ago

Hi @victoryftw , I've just made a new release. Please check, and reopen this issue if there still are problems.

victoryftw commented 9 years ago

The issue is resolved for me. Thanks for the quick and thorough response.

princemaple commented 9 years ago

Cool :) No problem

On Wed, 26 Nov 2014 05:31 Jake Epstein notifications@github.com wrote:

The issue is resolved for me. Thanks for the quick and thorough response.

— Reply to this email directly or view it on GitHub https://github.com/SublimeText/RSpec/issues/51#issuecomment-64447685.

jtippett commented 7 years ago

I also encountered this issue on an app with an "interesting" file structure; my hack to fix it is here: https://github.com/jtippett/RSpec/commit/8bf2a025afed3d0ebdb1c7d7becf82eb80ddaf23

If anyone else is having this issue, the changes necessary to adapt to your own situation should be pretty obvious from the commit.