Some Progress Made

For this week, I wanted to provide an update on my release 1 (issue 64679). I ran into problems with VSCode because I downloaded the latest LTS. It turns out that VSCode is incompatible with 10.x and I needed to use the 8.x.

Now onto the Issue
The maintainer made a couple of points that I could make to improve my PR:

  • I would generate `IIdentifiedSingleEditOperation` and drop the entire `DeleteLinesCommand`, i.e.
  • I would loop over all selections, and collect all lines to be deleted.
  • I would make sure to dedup them (like a set reunion) and then issue clear edits that never overlap.
  • I would then insert a cursor under each such deletion.

My solution was to get all of the selections and delete duplicate selections on the same line.
However, after I implemented this solution it would not delete the last line of the selection. After doing some search I figured out that it was because of how deleting lines in VSCode works. In VSCode, there is no way to say delete line n. Instead you need to create a selection and select the range you want to delete. This makes it awkward to delete lines because you need to grab the line above if you want to remove the selected line.

My Code:

if (editor) {
	if (cursors![cursors.length - 1].endLineNumber < editor.getModel().getLineCount()) {
		cursors!.push(new Selection(cursors![cursors.length - 1].endLineNumber + 1, 1, cursors![cursors.length - 1].endLineNumber + 1, 1));
	for (let i = 0; i < cursors.length - 1; i++) {
		editsMore.push(EditOperation.delete(new Range(cursors[i].selectionStartLineNumber, 1, cursors[i].selectionStartLineNumber + 1, 1)));
	editsMore.push(EditOperation.delete(new Range(23, 13, 24, 8)));

The result in VSCode:

The command did not fully delete the last line and instead left a blank line. This is because my command deleted at the first character on the first line to the last character on the last line.
I discovered this code would work:

editsMore.push(EditOperation.delete(new Range(18,1,21,1)));
editsMore.push(EditOperation.delete(new Range(22,24,25,11)));


It looks like I need to use grab the line above in order to delete the line properly. I need to add a lot more check, then I anticipated in order to get my code working.
This issue will take me longer than expected to implement due to the edge cases involved in this one. I believe that this PR will take an additional week to resolve.

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