Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join Lines: not multi cursor aware #16587

Closed
bpasero opened this issue Dec 6, 2016 · 4 comments
Closed

Join Lines: not multi cursor aware #16587

bpasero opened this issue Dec 6, 2016 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-contrib Editor collection of extras editor-multicursor Editor multiple cursor issues
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Dec 6, 2016

Testing: #16545

Steps to Reproduce:

  1. set multiple cursors
  2. run "Join Lines" command

=> only happens for the first cursor

@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Dec 6, 2016
@rebornix rebornix added this to the November 2016 milestone Dec 7, 2016
@rebornix rebornix added the verification-needed Verification of issue is requested label Dec 7, 2016
@bpasero
Copy link
Member Author

bpasero commented Dec 8, 2016

@rebornix when I run this action having multiple cursors on a single line, I loose the cursors and get a selection. When I undo and redo, I am not seeing that though:

view-picker

@bpasero bpasero reopened this Dec 8, 2016
@bpasero bpasero added the verification-found Issue verification failed label Dec 8, 2016
@rebornix
Copy link
Member

rebornix commented Dec 8, 2016

Changing multi cursors into one selection is not intentional, it's already fixed.

For one single cursor, we move the cursor before the newly added space and next line's trimmed content. For one single selection, we still persist the selection. This is the normal behavior of both Vim and Sublime Text.

When we take multi cursor into consideration, if people put multi cursor in one single line, running Join Lines on every cursor leads to the same result, so these cursors merge into a single one.

multicursor-combat

Above the behavior after the fix. However, there are still issues about the undo/redo stack. As we need to modify the cursor position after executing the commands, an undo followed by a redo will generate wrong cursor positions. This happens both here and Delete All Left.

redo

@alexandrudima it seems that we are not getting expected cursors while redoing editor.executeEdits, any hint on this? IMHO this one can be fixed in following iteration.

@rebornix rebornix modified the milestones: November 2016, January 2017 Dec 8, 2016
@alexdima
Copy link
Member

alexdima commented Dec 9, 2016

executeEdits goes into model.pushEditOperations which gets a cursor state computer that returns where the cursors end up according to markers logic. We could enhance executeEdits to optionally take a second argument resultingSelections which would be set on the cursor and in the cursor state computer.

public executeEdits(source: string, edits: editorCommon.IIdentifiedSingleEditOperation[]): boolean {
	if (!this.cursor) {
		// no view, no cursor
		return false;
	}
	if (this._configuration.editor.readOnly) {
		// read only editor => sorry!
		return false;
	}

	this.model.pushEditOperations(this.cursor.getSelections(), edits, () => {
		return this.cursor.getSelections();
	});

	return true;
}

@bpasero bpasero removed the verification-needed Verification of issue is requested label Dec 9, 2016
@rebornix rebornix modified the milestones: Backlog, January 2017 Jan 26, 2017
@rebornix rebornix added the editor-contrib Editor collection of extras label Apr 6, 2017
@rebornix rebornix added the editor-multicursor Editor multiple cursor issues label May 1, 2017
@rebornix
Copy link
Member

This issue was already fixed by community.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 5, 2018
@rzhao271 rzhao271 removed the verification-found Issue verification failed label Oct 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-contrib Editor collection of extras editor-multicursor Editor multiple cursor issues
Projects
None yet
Development

No branches or pull requests

4 participants