"use strict";
const editorExtensions = require("../../../browser/editorExtensions.js");
const editorContextKeys = require("../../../common/editorContextKeys.js");
const moveCaretCommand = require("./moveCaretCommand.js");
const nls = require("../../../../nls.js");
class MoveCaretAction extends editorExtensions.EditorAction {
  constructor(left, opts) {
    super(opts);
    this.left = left;
  }
  run(accessor, editor) {
    if (!editor.hasModel()) {
      return;
    }
    const commands = [];
    const selections = editor.getSelections();
    for (const selection of selections) {
      commands.push(new moveCaretCommand.MoveCaretCommand(selection, this.left));
    }
    editor.pushUndoStop();
    editor.executeCommands(this.id, commands);
    editor.pushUndoStop();
  }
}
class MoveCaretLeftAction extends MoveCaretAction {
  constructor() {
    super(true, {
      id: "editor.action.moveCarretLeftAction",
      label: nls.localize("caret.moveLeft", "Move Selected Text Left"),
      alias: "Move Selected Text Left",
      precondition: editorContextKeys.EditorContextKeys.writable
    });
  }
}
class MoveCaretRightAction extends MoveCaretAction {
  constructor() {
    super(false, {
      id: "editor.action.moveCarretRightAction",
      label: nls.localize("caret.moveRight", "Move Selected Text Right"),
      alias: "Move Selected Text Right",
      precondition: editorContextKeys.EditorContextKeys.writable
    });
  }
}
editorExtensions.registerEditorAction(MoveCaretLeftAction);
editorExtensions.registerEditorAction(MoveCaretRightAction);
