refactor file_exists function#131
Merged
NTBBloodbath merged 2 commits intorest-nvim:mainfrom Aug 11, 2022
Merged
Conversation
NTBBloodbath
requested changes
Aug 10, 2022
Member
NTBBloodbath
left a comment
There was a problem hiding this comment.
Hey,
This is indeed a great catch, thanks for the refactoring!
I would like the change I suggested to be applied before merging tho, I feel like it's worth it to simplify codebase and improve its readability.
Cheers
Co-authored-by: Alejandro <bloodbathalchemist@protonmail.com>
Contributor
Author
|
Of course, it looks even better! |
NTBBloodbath
approved these changes
Aug 10, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since this implementation of the
file_existsfunction has the ability to give an answer as to whether or not a file exists, it is not completely accurate since giving theopenfunction a directory path as an argument will still returntrueindicating that the file exists even though it is not actually a file.so I refactored the function, making use of the built-in function
'vim.fn.filereadable, to ensure that first we are verifying that we are actually reading a file and not a directory, and in turn showing if this file exists or not.In this way when running the
read_env_filefunction and there is a virtual environment (directory) with the name.envin the current directory, only the.envfiles will be taken into account and not the directory, preventingio.linesfrom trying to scan a directory.