MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / ensureSingleEditor

Function ensureSingleEditor

src/util/targetUtils.ts:5–17  ·  view source on GitHub ↗
(targets: TypedSelection[])

Source from the content-addressed store, hash-verified

3import { TypedSelection } from "../typings/Types";
4
5export 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
19export function ensureSingleTarget(targets: TypedSelection[]) {
20 if (targets.length !== 1) {

Callers 5

runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90
runMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected