| 3 | import { TypedSelection } from "../typings/Types"; |
| 4 | |
| 5 | export function ensureSingleEditor(targets: TypedSelection[]) { |
| 6 | if (targets.length === 0) { |
| 7 | throw new Error("Require at least one target with this action"); |
| 8 | } |
| 9 | |
| 10 | const editors = targets.map((target) => target.selection.editor); |
| 11 | |
| 12 | if (new Set(editors).size > 1) { |
| 13 | throw new Error("Can only have one editor with this action"); |
| 14 | } |
| 15 | |
| 16 | return editors[0]; |
| 17 | } |
| 18 | |
| 19 | export function ensureSingleTarget(targets: TypedSelection[]) { |
| 20 | if (targets.length !== 1) { |