-
Notifications
You must be signed in to change notification settings - Fork 4
Sort resource paths by load order. #71
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
Conversation
FichteFoll
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ResourcePath in syntax is very nice. However, this requires a few changes.
|
Given:
I suggest that for the time being we:
Then, we can add ordering (in 1.2 or another release) when we work out the details and if it won't be a mess. Meanwhile, if a user wants to sort a list of Sound reasonable? |
|
Yes to all. We could still implement a function to order resources properly (using cached (installed/default) packages lists), but that should be somewhere else and not in |
|
Removed explicit comparison and added a function for use in Because Given that we're hopefully expecting a new API method to solve the problem for syntaxes, this should probably do the trick for now. |
st3/sublime_lib/resource_path.py
Outdated
| } | ||
|
|
||
|
|
||
| def sort_by_load_order(paths): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to have a docstring here explaining roughly what it does (i.e. to what point it mirrors the internal order).
Case-insensitivity is missing, as far as I can tell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented case-insensitivity.
We're not exporting the method, so users will only see the comments if they look at the code. At that point, I think that an explicit description of the algorithm would be redundant with the code.
Do we know of any specific cases in which the current logic will fail? If so, then we should definitely fix or document those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not exported, but I believe this makes sense to document even for internal use. Most specifically, I wanted to either have case-insensitivity implemented or the fact it's missing documented.
I believe that we hit all known corner cases currently. The easiest way to check would be to verify that sorting a list returned by sublime.find_resources('') does not change it. With a couple extra edge cases added manually, if desired. That could even be unittested, although that is relying on the implementation detail of find_resources returning things in order, until a different API that ensures this is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After more testing, it looks like the current implementation still sorts some paths differently from sublime.find_resources (e.g. .DS_Store). If sublime.find_resources is the closest we have to a canonical load order, then I may as well just modify syntax to use that ordering directly and remove all of the explicit sorting code. I wish I could be sure that that's absolutely correct, but it might be good enough to tide us over until the new API method obviates the whole thing.
|
Latest commit removes all load order sorting and modifies |
Closes #67.
A resource's package is significant even if the resource is in
Cache, so I think it makes sense to expose thepackageproperty for those paths. Then, I don't see any reason to disable it for other paths.The
syntaxsubmodule cares about load order, so I improved the implementation to useResourcePath.