Work with VSCode Issue

So this blog will show my first attempt to work with an issue in a big open source project. The issue I will be looking at is issue #26956 – Can’t find files starting with `./` on MacOS.

Reproduce the issue
Open your VSCode repo in the terminal, and start the dev build

./scripts/code.sh

Let’s say we want to look for yarn.lock file under the root, Command+P for quick open, type in “./yarn.lock”, it results in “No results found”.
Screen Shot 2018-03-04 at 4.07.02 PM

Issue reproduced.


Try to locate and start debugging:

Use Command+Alt+I to toggle Developer Tools

1. Find the related HTML block
Screen Shot 2018-03-04 at 4.14.39 PM

2. Break on attribute modifications
Screen Shot 2018-03-04 at 4.15.44 PM

This will start the debugger immediately every time you trigger Command+Pand give you the Call Stack, which might give you some possible areas to locate the related codes:
Screen Shot 2018-03-04 at 4.23.38 PM

In this case, we will focus on quickOpenWidget.ts and quickOpenController.ts.

3. Skim through the codes & set breakpoints
InquickOpenWidget.ts, there’s a method called onType() which reads our input, let’s set a breakpoint and press F8 to resume.

Screen Shot 2018-03-04 at 8.27.05 PM

Press F11 to step into the highlighted callback, which brings us to quickOpenController.ts, continue F11, you will see:

Screen Shot 2018-03-04 at 9.59.06 PM

4. Start debugging

F10 to jump to next call
F11 to view detail of the call
F12 to step out current call

As you go deeper, you will find the promising getResults() method:

Screen Shot 2018-03-04 at 10.06.23 PM

After the prepareQuery() method, our query variable still looks good, especially it detects that our input contains path separator:

Screen Shot 2018-03-04 at 10.10.57 PM

Continuing exploring. . .  Some interesting methods might be relevant:

Screen Shot 2018-03-05 at 10.26.50 PM

. . .


Assumption & Conclusion:

After many times debugging, IMO somehow the searching algorithm does not recognize “./” as the root directory, instead it represents any directory (and sub-directory) that contains a dot for their names. So I am guessing “.” is treated as a file pattern rather than a root indicator when doing the searching.

Screen Shot 2018-03-05 at 12.15.57 AM

Actually, a simple yet awkward fix will make it works, however, you will lose the ability to use the dot as a file pattern for searching. Also surprisingly, this fix does not break the unit tests.

Screen Shot 2018-03-05 at 10.05.00 PM

Therefore, instead of “fixing” the issue, I think probably a new feature should be implemented. In that case, the fix won’t break any existing features since the quick open just provides a way for you to quickly finding resources based on your keyword input. For example, if you want to search “yarn.lock” under the root, simply typing in the name, then it will appear in the result.

To be continued.

Leave a comment