@witchcraft/spellcraft
    Preparing search index...
    • Swaps the given chords for all matching shortcuts.

      This is done by using forceUnequal for each set of matching shortcuts in turn.

      EXAMPLES:

      Given the following shortcuts:

      1 A
      1 B
      2 C
      2 D

      swapChords([[1]], [[2]]) would result in:

      2 A
      2 B
      1 C
      1 D

      Multiple chords, and chords of unequal lengths can be safely swapped.

      1 2 A
      1 2 B
      3 C
      3 D

      swapChords([[1], [2]], [[3]]):

      3 A
      3 B
      1 2 C
      1 2 D

      A filter function is provided, to, for example, filter out disabled entries from the swap. Note that it might be unsafe to swap entries with a filter if the new entries can be equal to the ignored ones, hence why the check exists.

      Example of how it might be a problem:

      A
      B

      shortcutSwapChords([[A]], [[B]], () => { filter that ignores A }) would result in two A shortcuts.

      But if, for example, you use the filter to ignore disabled shortcuts, this wouldn't be a problem because you'd get two unequal shortcuts (A and A(disabled)), though re/dis-abling one of them would trigger a conflict.

      Note: Certain types of chords cannot be swapped, like empty chords, or chords which share a base.

      If using the experimental ignoreModifierConflicts Shortcuts["ignoreModifierConflicts"], note that you cannot use this to swap the base modifiers.

      For example, say you had:

      Ctrl+A
      Ctrl

      If you do swapChords([Ctrl],[Shift]), Ctrl+A is not considered to match the [Ctrl] chord and you will get:

      Ctrl+A
      Shift

      Parameters

      • shortcuts: Shortcuts
      • chainA: string[][]
      • chainB: string[][]
      • manager: Pick<Manager, "shortcuts" | "commands" | "keys"> & PickManager<
            "options",
            "stringifier"
            | "sorter"
            | "conditionEquals"
            | "evaluateCondition",
        >
      • __namedParameters: { check?: boolean | "only" } = {}
      • Optionalfilter: (shortcut: Shortcut) => boolean

      Returns Result<true, Error | KnownError<"DUPLICATE_SHORTCUT" | "INVALID_SWAP_CHORDS">>