First PR of the Year

For this week’s release, I finally got to work on VSCode.

The first PR I made was to address this bug. It was a bit concerning that someone commented saying that he could not replicate the bug. I was able to duplicate both points the user makes. The first point was when a user had two selections on a line with multiple lines selected and used Delete Lines, this made none of the lines delete.

The second point the user makes is when deleting multiple lines will cause the left over cursors to be present.

I first started by debugging VSCode and came across a class which caught my attention. In linesOperations.ts it had a Action called DeleteLinesAction which contained all the code that was used to delete lines. I decided to take a look at run first and found that it used `executeCommands`. For my previous experience I know that executeCommands can cause a lot of problems with multi-cursor.

My solution to fix this was to add a executeEdit which contained the primary selection. What I did was grab the primary selection and told it to only use the primary cursor. After I made my changes, it worked.

The code looked like this:

let edits: IIdentifiedSingleEditOperation[] | null = [];
let cursors = editor.getSelections();
let cursorState = new Selection(cursors![0].selectionStartLineNumber, cursors![0].selectionStartColumn, cursors![0].selectionStartLineNumber, cursors![0].selectionStartColumn);
let endCursorState: Selection[] | null = [];

The end result of my fix is these this:


And this:


When implementing the tests for this feature, I noticed there was a similar issue. In this one, someone had similar problems but they didn’t have multiple cursors on multiple lines. Like I mentioned before, multi-cursor seems to have a lot of problems and this issue seems to be an extension of that issue.
After I submitted my PR, VSCode’s CI threw a error saying that my code didn’t conform to Typescript’s strict null check. This error took me a bit of time to figure out but I found that I need to use ! in my code. The ! meant that the value is non-null. This guide was helpful with null checks.

Currently, the PR is waiting for review.


I wanted to get started on an algorithm that would fix the problems with Emmet ranking fs vs fz when typing fsz. One thing that annoyed me about VSCode is how Mocha tests do not build before testing so I need to use npm run build before running.

I incremented the variable for each time the abbr character matched the string. Then if the count was less then the string length, it then ranked based on full string. With that change implemented, it passed the tests I set. However, I still need to test how this change impacts the rest of the tests.

This week was a lot more productive with a PR made and more work done on Emmet.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s