After finally setting up VSCode, I was ready to rumble! I found my first match who had been waiting eagerly for a challenger since May 19, 2017.
The issue: Quick Open cannot find files if user enters ‘./’ for current working directory(CWD).
Reproducing the issue: this was confirmed on both Mac and Windows OS as shown below:
Below outlines my attempt at figuring out the cause of this bad boy:
- Casted my net wide in the HTML code to get a rough idea of what class might handle the functionality of loading path.
- Dove into QuickOpenController.ts and noticed that getResults() handles a call for prepareQuery(), which to my understanding cleans the search value of irregularities. This function uses the query to return a list of search history ranked by score, a rank/priority given to each file (The exact formula to calculate score is classified…maybe you can find it?).
- At the same time, I’ve set some break points in FileService.ts, specifically at resolveFileData(). With a name like ‘file service’, you’d think the program would make a pit stop here to do something related to opening files…nope~
- Continuing from #2, I dove into QuickOpenScorer.ts to examine prepareQuery(). A gem immediately poped out to me:
My initial thought on the issue was that nobody considered using CWD when searching in Quick Open. So my naive solution was simply:
Did it work? yes and no…
My gut feeling tells me something is off, and the ‘fix’ was a facade. So I did not jump to the conclusion and consulted my professor David Humphrey on Slack.
I completely forgot that ‘.’ is a wildcard :P!
- Looking into query values was just the surface, I needed to go deeper! Maybe classes that handles opening files has something fishy going on. OpenFileHandler looked interesting, specifically the call to doFindResults(). This function looks for the file requested.
- Within doFindResults(), it calls queryBuilder’s query() function, passing it an Options object:
Options.includePattern is passed to parseSearchPaths(), but it is undefined!
This is where I narrowed the issue down. My suspicion is that somewhere, ‘./’ is not noted as a pattern to include for parseSearchPaths(). Hopefully, I’ll get to finish what I started in the following weeks.
Summary of tools and technique used:
- Developer tools
- Break points
- Consulting with others
What did I learn?
- Trust your gut feeling
- Understand the problem, before looking for the cause!
Hope you enjoyed the read,
Hao-ut (Hao out~)