projectile icon indicating copy to clipboard operation
projectile copied to clipboard

add sort by path length & custom method

Open dradetsky opened this issue 6 years ago • 8 comments

I wanted to be able to sort the list of files for projectile-find-file by the length of the full path. The reason is that if I want to find models/user.rb and I'm presented with

models/special_case/user_hamburger.rb
models/user.rb

I can only get the one I want by navigating in the completion window, which is cumbersome (or maybe there's another way, but I don't know it), rather than just doing more incremental completion. There's nothing to type to narrow down to just the file I want (or nothing short).

By contrast, if I'm presented with that list in reverse, and I actually am looking for user_hamburger.rb, I can get to it with incremental completion, and I can see what letters to type to get there.

I originally started out to add an option to sort the list by a custom method, so I could add my own sort-by-path-length method and use that. When I finished, I considered that enough other users would want to sort by path length that I might as well add an option to do that. So I did, and that's what I now use for my sort method, rather than the custom method.

I considered removing the sort-by-custom-method code, but thought that the maintainers might think both were useful. I can remove one or the other if the maintainers think it's too much.

NOTE: I don't really know how to write cask tests. I looked and I didn't see any tests for the existing sorting or even for projectile-project-files, so I presume not writing tests for my change is okay. I did manage to install cask & butterfly & confirm that I at least didn't break any existing tests.


Before submitting a PR make sure the following things have been done (and denote this by checking the relevant checkboxes):

  • [x] The commits are consistent with our contribution guidelines i think so, kinda
  • [x] You've added tests (if possible) to cover your change(s) arguably not possible
  • [x] All tests are passing (make test)
  • [x] The new code is not generating bytecode or M-x checkdoc warnings as far as i can tell, although checkdoc says all kinds of stuff is wrong so i could have missed something
  • [x] You've updated the changelog (if adding/changing user-visible functionality)
  • [x] You've updated the readme (if adding/changing user-visible functionality)

Thanks!

dradetsky avatar Aug 27 '19 23:08 dradetsky

@bbatsov rebased/merged for conflicts

dradetsky avatar Sep 18 '19 19:09 dradetsky

The proposed changes look OK to me. I've added some small remarks.

bbatsov avatar Oct 06 '19 09:10 bbatsov

Looking at the failing build it seems there's a syntax error somewhere.

bbatsov avatar Oct 16 '19 05:10 bbatsov

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

stale[bot] avatar Nov 26 '20 21:11 stale[bot]

@dradetsky You'll also need to rebase on top of master.

bbatsov avatar Dec 03 '20 08:12 bbatsov

@bbatsov just came across this again (been kind of busy). I'll try to fix it soon. In the meantime, if you want to fix it yourself or just steal bits of it that's totally cool.

dradetsky avatar Jan 22 '21 21:01 dradetsky

@dradetsky Any chance of you rebasing/wrapping this up?

bbatsov avatar May 24 '21 12:05 bbatsov

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

stale[bot] avatar Apr 16 '22 08:04 stale[bot]