Open peterflynn opened 10 years ago
Assigning to myself because I may have already fixed this in the project manager work...
Fwiw, looks like it's not fixed yet, since ProjectModel.getAllFiles()
directly modifies the result
array that _getAllFilesCache()
hands back, affecting the value all future calls will see.
Yeah, this is still on my list. Should be a trivial fix (just add a _.clone
).
Invoking
ProjectManager.getAllFiles()
(or more explicitly,ProjectManager.getAllFiles(null, false)
) often yields an array that includes files outside the project that are open in the working set. This happens any time someone has calledProjectManager.getAllFiles(true)
earlier.Most callers supposedly don't want working-set entries that are outside the project -- only Find in Files & Quick Open pass
true
. But since this bug has existed seemingly since Sprint 36 (a7a551d4f72092ac69b4aa2003a629072f2d0b03), those callers have been getting project-external items in the result list anyway. So presumably this doesn't cause any major ill effects for most callers.This happens because getAllFiles() reuses a cached result, and when
includeWorkingSet
is true it modifies the cache in-place to include the extra files. It should make a copy instead to prevent tainting the cache used by future callers.