Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(module:code-editor): memorize cursor position and selections (#6044)
Calling #setValue() on a monaco editor instance causes the mouse cursor to jump to the beginning of the document, which is undesirable for a ControlValueAccessor implementation which should only update the content. Also see microsoft/monaco-editor#1397 for more information. Unfortunately, using #executeEdits() doesn't really work as a replacement because it will mess with selections. Therefore we memorize and restore the cursor position before/after setting the value. Since #setValue() also causes a selection to be lost we do the same for those. Restoring selections may produce slightly unexpected results if the selection covers part of the content that has been changed, but is still preferable to losing the selection altogether. fixes #6038
- Loading branch information