Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Move Line(s) Up in inline editor does not keep correct highlight of the moved lines #1343

Closed
RaymondLim opened this issue Aug 3, 2012 · 15 comments · Fixed by #2731
Closed
Assignees
Milestone

Comments

@RaymondLim
Copy link
Contributor

  1. Open an inline editor with at least four lines.
  2. Select three lines and then move those highlighted line with Ctrl+Shift+Up arrow key.

Result: Only the first two (just moved) lines are highlighted, not all three lines. If you repeat step 1 and 2 again, then you lose another line in highlight.

@peterflynn
Copy link
Member

This only happens when moving lines up -- not down. Updating description...

@peterflynn
Copy link
Member

The EditorCommandHandlers code is requesting the correct selection when it calls setSelection(), and Editor even reports that same selection after that call... but then a moment later, the selection becomes incorrect. I think the problem is that we're setting selection within the same batch operation that edited the text. CodeMirror appears to defer some processing of the text updates but not the selection updates -- it appears to actually set the selection first and then process the text edits, losing the top line of the selection in the process.

Not clear if that's a CodeMirror bug, feature, or what... needs a bit more investigation.

@ghost ghost assigned peterflynn Aug 6, 2012
@pthiess
Copy link
Contributor

pthiess commented Aug 7, 2012

Reviewed

@gruehle
Copy link
Member

gruehle commented Aug 28, 2012

Moving to sprint 14.

@njx
Copy link

njx commented Aug 30, 2012

Moving to sprint 15.

@peterflynn
Copy link
Member

I should still be able to investigate this one within Sprint 15

@gruehle
Copy link
Member

gruehle commented Oct 17, 2012

Moving to sprint 16.

@pthiess
Copy link
Contributor

pthiess commented Nov 6, 2012

Moved out to later (sprint 18) after the V3 has been merged

@peterflynn
Copy link
Member

CM v3 won't be merged in Sprint 18, so moving further out...

@njx
Copy link

njx commented Jan 14, 2013

Moving to sprint 20 since we're not doing the final v3 merge until then.

@ghost ghost assigned njx Jan 30, 2013
@peterflynn
Copy link
Member

Note: I was wrong about the old external pull request. I don't believe #2431 is related to this issue.

@njx
Copy link

njx commented Jan 31, 2013

Still reproduces in v3.

@njx
Copy link

njx commented Jan 31, 2013

Actually, it's not a bug in CodeMirror--it was a bonafide bug in our code. The issue is that the batching is happening on the "document" (which is really the full editor), but we're setting the selection on the inline editor. So the selection is getting set on the inline editor, then the operation ends (updating the document), then the document change gets synced back to the inline editor (modifying the selection we had just set). The fix is just to move the setting of the inline editor's selection out of the document's operation, since it doesn't really belong in there anyway.

@peterflynn
Copy link
Member

FBNC @RaymondLim

@ghost ghost assigned RaymondLim Feb 1, 2013
@RaymondLim
Copy link
Contributor Author

Fix confirmed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants