22 LineNumberMark ,
33 Modifier ,
44 PartialMark ,
5- PartialPrimitiveTargetDescriptor , RelativeScopeModifier ,
6- ScopeType
5+ PartialPrimitiveTargetDescriptor ,
6+ RelativeScopeModifier ,
7+ ScopeType ,
78} from "@cursorless/common" ;
89import { RecursiveArray } from "lodash" ;
910import { NoSpokenFormError } from "./NoSpokenFormError" ;
@@ -13,24 +14,24 @@ import {
1314 hatColorToSpokenForm ,
1415 hatShapeToSpokenForm ,
1516 lineDirections ,
16- marks
17+ marks ,
1718} from "./defaultSpokenForms/marks" ;
1819import {
1920 modifiers ,
2021 modifiersExtra ,
2122 scopeSpokenForms ,
2223 surroundingPairForceDirections ,
23- surroundingPairNameToSpokenForm
24+ surroundingPairNameToSpokenForm ,
2425} from "./defaultSpokenForms/modifiers" ;
2526import {
2627 numberToSpokenForm ,
27- ordinalToSpokenForm
28+ ordinalToSpokenForm ,
2829} from "./defaultSpokenForms/numbers" ;
2930import { getRangeConnective } from "./getRangeConnective" ;
3031
31-
3232export function primitiveTargetToSpokenForm (
33- target : PartialPrimitiveTargetDescriptor ) : RecursiveArray < string > {
33+ target : PartialPrimitiveTargetDescriptor ,
34+ ) : RecursiveArray < string > {
3435 const components : RecursiveArray < string > = [ ] ;
3536 if ( target . modifiers != null ) {
3637 components . push ( target . modifiers . map ( modifierToSpokenForm ) ) ;
@@ -96,23 +97,26 @@ function modifierToSpokenForm(modifier: Modifier): RecursiveArray<string> {
9697 }
9798
9899 throw new NoSpokenFormError (
99- `'${ modifier . type } ' with count > 1 and offset away from start / end`
100+ `'${ modifier . type } ' with count > 1 and offset away from start / end` ,
100101 ) ;
101102 }
102103
103104 case "range" : {
104- if ( modifier . anchor . type === "ordinalScope" &&
105+ if (
106+ modifier . anchor . type === "ordinalScope" &&
105107 modifier . active . type === "ordinalScope" &&
106108 modifier . anchor . length === 1 &&
107109 modifier . active . length === 1 &&
108- modifier . anchor . scopeType . type === modifier . active . scopeType . type ) {
109- const anchor = modifier . anchor . start === - 1
110- ? modifiersExtra . last
111- : ordinalToSpokenForm ( modifier . anchor . start + 1 ) ;
110+ modifier . anchor . scopeType . type === modifier . active . scopeType . type
111+ ) {
112+ const anchor =
113+ modifier . anchor . start === - 1
114+ ? modifiersExtra . last
115+ : ordinalToSpokenForm ( modifier . anchor . start + 1 ) ;
112116 const active = modifierToSpokenForm ( modifier . active ) ;
113117 const connective = getRangeConnective (
114118 modifier . excludeAnchor ,
115- modifier . excludeActive
119+ modifier . excludeActive ,
116120 ) ;
117121 return [ anchor , connective , active ] ;
118122 }
@@ -128,14 +132,15 @@ function modifierToSpokenForm(modifier: Modifier): RecursiveArray<string> {
128132}
129133
130134function relativeScopeInclusiveToSpokenForm (
131- modifier : RelativeScopeModifier
135+ modifier : RelativeScopeModifier ,
132136) : RecursiveArray < string > {
133137 const scope = scopeTypeToSpokenForm ( modifier . scopeType ) ;
134138
135139 if ( modifier . length === 1 ) {
136- const direction = modifier . direction === "forward"
137- ? connectives . forward
138- : connectives . backward ;
140+ const direction =
141+ modifier . direction === "forward"
142+ ? connectives . forward
143+ : connectives . backward ;
139144
140145 // token forward/backward
141146 return [ scope , direction ] ;
@@ -155,10 +160,11 @@ function relativeScopeInclusiveToSpokenForm(
155160}
156161
157162function relativeScopeExclusiveToSpokenForm (
158- modifier : RelativeScopeModifier
163+ modifier : RelativeScopeModifier ,
159164) : RecursiveArray < string > {
160165 const scope = scopeTypeToSpokenForm ( modifier . scopeType ) ;
161- const direction = modifier . direction === "forward" ? connectives . next : connectives . previous ;
166+ const direction =
167+ modifier . direction === "forward" ? connectives . next : connectives . previous ;
162168
163169 if ( modifier . offset === 1 ) {
164170 const number = numberToSpokenForm ( modifier . length ) ;
@@ -181,7 +187,7 @@ function relativeScopeExclusiveToSpokenForm(
181187 }
182188
183189 throw new NoSpokenFormError (
184- `${ modifier . type } modifier with offset > 1 and length > 1`
190+ `${ modifier . type } modifier with offset > 1 and length > 1` ,
185191 ) ;
186192}
187193
@@ -195,9 +201,10 @@ function scopeTypeToSpokenForm(scopeType: ScopeType): string {
195201 case "surroundingPair" : {
196202 const pair = surroundingPairNameToSpokenForm ( scopeType . delimiter ) ;
197203 if ( scopeType . forceDirection != null ) {
198- const direction = scopeType . forceDirection === "left"
199- ? surroundingPairForceDirections . left
200- : surroundingPairForceDirections . right ;
204+ const direction =
205+ scopeType . forceDirection === "left"
206+ ? surroundingPairForceDirections . left
207+ : surroundingPairForceDirections . right ;
201208 return `${ direction } ${ pair } ` ;
202209 }
203210 return pair ;
@@ -228,14 +235,16 @@ function markToSpokenForm(mark: PartialMark): RecursiveArray<string> {
228235 }
229236
230237 case "range" : {
231- if ( mark . anchor . type === "lineNumber" &&
232- mark . active . type === "lineNumber" ) {
238+ if (
239+ mark . anchor . type === "lineNumber" &&
240+ mark . active . type === "lineNumber"
241+ ) {
233242 const [ typeAnchor , numberAnchor ] = lineNumberToParts ( mark . anchor ) ;
234243 const [ typeActive , numberActive ] = lineNumberToParts ( mark . active ) ;
235244 if ( typeAnchor === typeActive ) {
236245 const connective = getRangeConnective (
237246 mark . excludeAnchor ,
238- mark . excludeActive
247+ mark . excludeActive ,
239248 ) ;
240249 // Row five past seven
241250 return [ typeAnchor , numberAnchor , connective , numberActive ] ;
0 commit comments