Skip to content

Commit ca743f8

Browse files
Merge branch 'main' into selectedScopeVisualizer
2 parents 3346be5 + b0af101 commit ca743f8

File tree

9 files changed

+205
-88
lines changed

9 files changed

+205
-88
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
languageId: typescript
2+
command:
3+
version: 7
4+
spokenForm: bring name
5+
action:
6+
name: replaceWithTarget
7+
source:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
destination: {type: implicit}
13+
usePrePhraseSnapshot: false
14+
initialState:
15+
documentContents: |-
16+
function aaa() {
17+
;
18+
;
19+
}
20+
21+
function bbb() {
22+
;
23+
}
24+
selections:
25+
- anchor: {line: 1, character: 2}
26+
active: {line: 1, character: 2}
27+
- anchor: {line: 2, character: 2}
28+
active: {line: 2, character: 2}
29+
- anchor: {line: 6, character: 2}
30+
active: {line: 6, character: 2}
31+
marks: {}
32+
finalState:
33+
documentContents: |-
34+
function aaa() {
35+
aaa;
36+
aaa;
37+
}
38+
39+
function bbb() {
40+
bbb;
41+
}
42+
selections:
43+
- anchor: {line: 1, character: 5}
44+
active: {line: 1, character: 5}
45+
- anchor: {line: 2, character: 5}
46+
active: {line: 2, character: 5}
47+
- anchor: {line: 6, character: 5}
48+
active: {line: 6, character: 5}
49+
thatMark:
50+
- type: UntypedTarget
51+
contentRange:
52+
start: {line: 1, character: 2}
53+
end: {line: 1, character: 5}
54+
isReversed: false
55+
hasExplicitRange: true
56+
- type: UntypedTarget
57+
contentRange:
58+
start: {line: 2, character: 2}
59+
end: {line: 2, character: 5}
60+
isReversed: false
61+
hasExplicitRange: true
62+
- type: UntypedTarget
63+
contentRange:
64+
start: {line: 6, character: 2}
65+
end: {line: 6, character: 5}
66+
isReversed: false
67+
hasExplicitRange: true
68+
sourceMark:
69+
- type: UntypedTarget
70+
contentRange:
71+
start: {line: 0, character: 9}
72+
end: {line: 0, character: 12}
73+
isReversed: false
74+
hasExplicitRange: true
75+
- type: UntypedTarget
76+
contentRange:
77+
start: {line: 0, character: 9}
78+
end: {line: 0, character: 12}
79+
isReversed: false
80+
hasExplicitRange: true
81+
- type: UntypedTarget
82+
contentRange:
83+
start: {line: 5, character: 9}
84+
end: {line: 5, character: 12}
85+
isReversed: false
86+
hasExplicitRange: true

data/fixtures/recorded/hatTokenMap/bringPointAndHarpToEndOfThisAndEndOfWhaleTakeWhale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ finalState:
5656
end: {line: 0, character: 5}
5757
default.w:
5858
start: {line: 0, character: 7}
59-
end: {line: 0, character: 12}
59+
end: {line: 0, character: 18}

data/scopeSupportFacetInfos.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119

120120
### disqualifyDelimiter
121121

122-
- `disqualifyDelimiter` Used to disqualify a token from being treated as a surrounding pair delimiter. This will usually be operators containing `>` or `<`, eg `<`, `<=`, `->`, etc
122+
- `disqualifyDelimiter` Internally used to disqualify a token from being treated as a surrounding pair delimiter. This will usually be operators containing `>` or `<`, eg `<`, `<=`, `->`, etc.
123123

124124
### document
125125

@@ -259,7 +259,7 @@
259259

260260
### pairDelimiter
261261

262-
- `pairDelimiter` A pair delimiter, eg parentheses, brackets, braces, quotes, etc
262+
- `pairDelimiter` Internally used to add additional language specific surrounding pair delimiters in addition to the text based definitions. eg `r"`.
263263

264264
### paragraph
265265

@@ -336,11 +336,11 @@
336336

337337
### textFragment
338338

339-
- `textFragment.comment.block` Text fragment consisting of a block comment
340-
- `textFragment.comment.line` Text fragment consisting of a line comment
341-
- `textFragment.element` Text fragment consisting of a xml element interior
342-
- `textFragment.string.multiLine` Text fragment consisting of a multi-line string
343-
- `textFragment.string.singleLine` Text fragment consisting of a single-line string
339+
- `textFragment.comment.block` Internally used text fragment consisting of a block comment
340+
- `textFragment.comment.line` Internally used text fragment consisting of a line comment
341+
- `textFragment.element` Internally used text fragment consisting of a xml element interior
342+
- `textFragment.string.multiLine` Internally used text fragment consisting of a multi-line string
343+
- `textFragment.string.singleLine` Internally used text fragment consisting of a single-line string
344344

345345
### token
346346

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -474,38 +474,6 @@ export const scopeSupportFacetInfos: Record<
474474
scopeType: "string",
475475
},
476476

477-
"textFragment.comment.line": {
478-
description: "Text fragment consisting of a line comment",
479-
scopeType: "textFragment",
480-
},
481-
"textFragment.comment.block": {
482-
description: "Text fragment consisting of a block comment",
483-
scopeType: "textFragment",
484-
},
485-
"textFragment.string.singleLine": {
486-
description: "Text fragment consisting of a single-line string",
487-
scopeType: "textFragment",
488-
},
489-
"textFragment.string.multiLine": {
490-
description: "Text fragment consisting of a multi-line string",
491-
scopeType: "textFragment",
492-
},
493-
"textFragment.element": {
494-
description: "Text fragment consisting of a xml element interior",
495-
scopeType: "textFragment",
496-
},
497-
498-
disqualifyDelimiter: {
499-
description:
500-
"Used to disqualify a token from being treated as a surrounding pair delimiter. This will usually be operators containing `>` or `<`, eg `<`, `<=`, `->`, etc",
501-
scopeType: "disqualifyDelimiter",
502-
},
503-
pairDelimiter: {
504-
description:
505-
"A pair delimiter, eg parentheses, brackets, braces, quotes, etc",
506-
scopeType: "pairDelimiter",
507-
},
508-
509477
"branch.if": {
510478
description: "An if branch",
511479
scopeType: "branch",
@@ -1044,6 +1012,43 @@ export const scopeSupportFacetInfos: Record<
10441012
description: "A unit in a css rule set",
10451013
scopeType: "unit",
10461014
},
1015+
1016+
// Internal scope facets
1017+
1018+
"textFragment.comment.line": {
1019+
description: "Internally used text fragment consisting of a line comment",
1020+
scopeType: "textFragment",
1021+
},
1022+
"textFragment.comment.block": {
1023+
description: "Internally used text fragment consisting of a block comment",
1024+
scopeType: "textFragment",
1025+
},
1026+
"textFragment.string.singleLine": {
1027+
description:
1028+
"Internally used text fragment consisting of a single-line string",
1029+
scopeType: "textFragment",
1030+
},
1031+
"textFragment.string.multiLine": {
1032+
description:
1033+
"Internally used text fragment consisting of a multi-line string",
1034+
scopeType: "textFragment",
1035+
},
1036+
"textFragment.element": {
1037+
description:
1038+
"Internally used text fragment consisting of a xml element interior",
1039+
scopeType: "textFragment",
1040+
},
1041+
1042+
disqualifyDelimiter: {
1043+
description:
1044+
"Internally used to disqualify a token from being treated as a surrounding pair delimiter. This will usually be operators containing `>` or `<`, eg `<`, `<=`, `->`, etc.",
1045+
scopeType: "disqualifyDelimiter",
1046+
},
1047+
pairDelimiter: {
1048+
description:
1049+
'Internally used to add additional language specific surrounding pair delimiters in addition to the text based definitions. eg `r"`.',
1050+
scopeType: "pairDelimiter",
1051+
},
10471052
};
10481053

10491054
function documentIter(

packages/cursorless-engine/src/core/commandRunner/CommandRunnerImpl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class CommandRunnerImpl implements CommandRunner {
2727
private inferenceContext: InferenceContext;
2828
private finalStages: ModifierStage[] = [];
2929
private noAutomaticTokenExpansion: boolean | undefined;
30+
private allowDuplicateTargets: boolean | undefined;
3031

3132
constructor(
3233
private commandServerApi: CommandServerApi,
@@ -103,6 +104,7 @@ export class CommandRunnerImpl implements CommandRunner {
103104

104105
switch (actionDescriptor.name) {
105106
case "replaceWithTarget":
107+
this.allowDuplicateTargets = true;
106108
return this.actions.replaceWithTarget.run(
107109
this.getTargets(actionDescriptor.source),
108110
this.getDestinations(actionDescriptor.destination),
@@ -239,6 +241,7 @@ export class CommandRunnerImpl implements CommandRunner {
239241
return this.pipelineRunner.run(targetDescriptor, {
240242
actionFinalStages: this.finalStages,
241243
noAutomaticTokenExpansion: this.noAutomaticTokenExpansion,
244+
allowDuplicateTargets: this.allowDuplicateTargets,
242245
});
243246
}
244247

packages/cursorless-engine/src/processTargets/TargetPipelineRunner.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { PlainTarget } from "./targets";
2727
interface TargetPipelineRunnerOpts {
2828
actionFinalStages?: ModifierStage[];
2929
noAutomaticTokenExpansion?: boolean;
30+
allowDuplicateTargets?: boolean;
3031
}
3132

3233
export class TargetPipelineRunner {
@@ -53,13 +54,14 @@ export class TargetPipelineRunner {
5354
{
5455
actionFinalStages = [],
5556
noAutomaticTokenExpansion = false,
57+
allowDuplicateTargets = false,
5658
}: TargetPipelineRunnerOpts = {},
5759
): Target[] {
5860
return new TargetPipeline(
5961
this.modifierStageFactory,
6062
this.markStageFactory,
6163
target,
62-
{ actionFinalStages, noAutomaticTokenExpansion },
64+
{ actionFinalStages, noAutomaticTokenExpansion, allowDuplicateTargets },
6365
).run();
6466
}
6567
}
@@ -87,7 +89,8 @@ class TargetPipeline {
8789
* the target
8890
*/
8991
run(): Target[] {
90-
return uniqTargets(this.processTarget(this.target));
92+
const targets = this.processTarget(this.target);
93+
return this.opts.allowDuplicateTargets ? targets : uniqTargets(targets);
9194
}
9295

9396
processTarget(target: TargetDescriptor): Target[] {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.anchor-with-sticky-navbar {
2+
scroll-margin-top: calc(var(--ifm-navbar-height) + 0.5rem);
3+
}

packages/cursorless-org-docs/src/docs/components/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { uriEncodeHashId } from "@cursorless/common";
22
import React from "react";
3+
import "./Header.css";
34

45
interface Props {
56
className?: string;
@@ -35,8 +36,7 @@ function renderHeader(
3536
id={encodedId}
3637
title={title}
3738
className={
38-
"scope-header anchorWithStickyNavbar_IncK" +
39-
(className ? " " + className : "")
39+
"anchor-with-sticky-navbar" + (className ? " " + className : "")
4040
}
4141
>
4242
{children}

0 commit comments

Comments
 (0)