-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Cache the result of wmic logicaldisk get name
on Windows
#504
Conversation
WalkthroughThe changes introduce a new variable Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
autoload/fern/scheme/file/util.vim (1)
4-4
: Summary: Effective caching mechanism implemented for Windows drive listingThe changes introduce a caching mechanism for the
list_drives
function on Windows, which should significantly improve performance, especially in scenarios involving disconnected network drives. This implementation directly addresses the objectives outlined in the PR and should help resolve the freezing issue described in #501.Key points:
- The
Lambda
module is imported for cache management.- A cache variable is initialized and checked before executing the
wmic
command.- The cache is updated with the latest results after each execution.
These changes are well-structured, consistent with the existing codebase, and should provide a noticeable performance improvement for Windows users of the Fern plugin.
To further enhance this implementation, consider:
- Implementing a cache invalidation mechanism (as suggested in a previous comment).
- Adding a configurable cache expiration time to ensure that the cached drive list doesn't become stale over extended periods.
- Providing a way for users to manually refresh the drive list if needed.
These additions would make the caching mechanism more robust and flexible for various use cases.
Also applies to: 61-65, 72-72
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- autoload/fern/scheme/file/util.vim (2 hunks)
Additional comments not posted (2)
autoload/fern/scheme/file/util.vim (2)
4-4
: LGTM: Lambda module import addedThe addition of the
Lambda
module import is consistent with the existing import style and is necessary for the new caching mechanism implemented later in the file.
61-61
: LGTM: Cache initialization addedThe cache initialization is correctly placed within the Windows-specific section and uses
v:null
to indicate an unset cache, which is appropriate.
if s:list_drives_cache isnot# v:null | ||
return s:Promise.resolve(s:list_drives_cache) | ||
endif |
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.
🛠️ Refactor suggestion
LGTM: Caching mechanism implemented for list_drives
The caching mechanism for the list_drives
function is well-implemented and addresses the performance issue described in the PR objectives. This should help mitigate the freezing issue described in the linked issue #501, especially when dealing with disconnected network drives.
A minor suggestion for improvement:
Consider adding a cache invalidation mechanism or a way to refresh the cache. This could be useful in scenarios where drive configurations change dynamically. For example:
function! fern#scheme#file#util#invalidate_drives_cache() abort
let s:list_drives_cache = v:null
endfunction
This function could be called when necessary to force a refresh of the drives list.
Also applies to: 72-72
Original issue was closed so |
May close #501
Summary by CodeRabbit
New Features
Bug Fixes