message: Fix scrolling behaviour for most refactorings
diff: @@ -24,6 +24,12 @@ class VSCodeEditor implements Editor {
  }
  async write(code: Code, newCursorPosition?: Position): Promise<void> {
  + // We need to register initial position BEFORE we update the document.
  + const cursorAtInitialStartPosition = new vscode.Selection(
  + this.editor.selection.start,
  + this.editor.selection.start
  + );
  +
  const edit = new vscode.WorkspaceEdit();
  const allDocumentRange = new vscode.Range(
  new vscode.Position(0, 0),
  @@ -35,23 +41,19 @@ class VSCodeEditor implements Editor {
  await vscode.workspace.applyEdit(edit);
  // Put cursor at correct position
  - const cursorAtInitialStartPosition = new vscode.Selection(
  - this.editor.selection.start,
  - this.editor.selection.start
  - );
  this.editor.selection = newCursorPosition
  ? toVSCodeCursor(newCursorPosition)
  : cursorAtInitialStartPosition;
  - // Scroll to correct position
  - const position = newCursorPosition
  - ? toVSCodePosition(newCursorPosition)
  - : this.editor.selection.start;
  + // Scroll to correct position if it changed
  + if (newCursorPosition) {
  + const position = toVSCodePosition(newCursorPosition);
  this.editor.revealRange(
  new vscode.Range(position, position),
  vscode.TextEditorRevealType.InCenter
  );
  }
  + }
  async readThenWrite(
  selection: Selection,
  