make dirty files unique as nimsuggest expects (fixes #180) #182
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.
Fixes #180
Description:
include
s appeared to not be processed correctly. This is because nimsuggest (and the nim compiler) assumes that all dirty files are unique. However, nimsuggest was using 1 shared dirty file. This fix creates a directory structure in the sametmp
dir mirroring the project structure. EDIT: I could've used hashes for everything to make them unique, but decided to keep human-readable naming as much as possible so only used a hash postfix for the root dir, in case anything needs introspection later on or for debugging.Old tmp Structure:
/tmp/vscodenimdirty.nim
New tmp Structure:
/tmp/<project_dir_name>-<unique_number>/path/to/file/in/project
Old Behavior:
MWE in #180 shows autocompletion stops working when switching files
New Behavior:
autocompletion now works despite switching files
Possible issues:Should append a unique ID for the <project_dir_name>, otherwise multiple projects might end up clobbering each other.
For example, 2 projects with 1 clobbering file.
ProjectA/main.nim
ProjectA/moduleXYZ.nim
another/ProjectA/main.nim
another/ProjectA/moduleABC.nim
This would clobber in tmp as follows: /tmp/ProjectA/main.nim
I avoided the complete system path because some systems get cranky with long paths. Thoughts?
Fixed; see commit.