@@ -2,7 +2,13 @@ import * as yaml from "js-yaml";
2
2
import * as vscode from "vscode" ;
3
3
import { Position , Range , Selection } from "vscode" ;
4
4
import NavigationMap from "./NavigationMap" ;
5
- import { ActionType , PartialTarget , PrimitiveTarget , Target } from "./Types" ;
5
+ import {
6
+ ActionType ,
7
+ PartialTarget ,
8
+ PrimitiveTarget ,
9
+ SelectionWithEditor ,
10
+ Target ,
11
+ } from "./Types" ;
6
12
7
13
export type SerializedPosition = {
8
14
line : number ;
@@ -37,13 +43,19 @@ export function serializePosition(position: Position): SerializedPosition {
37
43
return { line : position . line , character : position . character } ;
38
44
}
39
45
40
- type Command = {
46
+ type TestCaseCommand = {
41
47
actionName : ActionType ;
42
48
partialTargets : PartialTarget [ ] ;
43
49
extraArgs : any [ ] ;
44
50
} ;
45
51
46
- type Snapshot = {
52
+ type TestCaseContext = {
53
+ thatMark : SelectionWithEditor [ ] ;
54
+ targets : Target [ ] ;
55
+ navigationMap : NavigationMap ;
56
+ } ;
57
+
58
+ type TestCaseSnapshot = {
47
59
document : string ;
48
60
clipboard : string ;
49
61
visibleRanges : SerializedRange [ ] ;
@@ -53,32 +65,32 @@ type Snapshot = {
53
65
type DecorationRanges = { [ coloredSymbol : string ] : SerializedRange } ;
54
66
55
67
export type TestCaseFixture = {
56
- command : Command ;
68
+ command : TestCaseCommand ;
57
69
targets : Target [ ] ;
58
70
languageId : string ;
59
- decorations : DecorationRanges ;
60
- initialState : Snapshot ;
61
- finalState : Snapshot ;
71
+ marks : DecorationRanges ;
72
+ thatMark : SerializedSelection [ ] ;
73
+ initialState : TestCaseSnapshot ;
74
+ finalState : TestCaseSnapshot ;
62
75
} ;
63
76
64
77
export default class TestCase {
65
- command : Command ;
78
+ command : TestCaseCommand ;
66
79
languageId : string ;
67
80
targets : Target [ ] ;
68
- decorations : DecorationRanges ;
69
- initialState : Snapshot | null = null ;
70
- finalState : Snapshot | null = null ;
71
-
72
- constructor (
73
- command : Command ,
74
- targets : Target [ ] ,
75
- navigationMap : NavigationMap
76
- ) {
81
+ marks : DecorationRanges ;
82
+ thatMark : SerializedSelection [ ] ;
83
+ initialState : TestCaseSnapshot | null = null ;
84
+ finalState : TestCaseSnapshot | null = null ;
85
+
86
+ constructor ( command : TestCaseCommand , context : TestCaseContext ) {
77
87
const activeEditor = vscode . window . activeTextEditor ! ;
88
+ const { thatMark, navigationMap, targets } = context ;
78
89
79
90
this . command = command ;
80
91
this . languageId = activeEditor . document . languageId ;
81
- this . decorations = this . extractTargetedDecorations ( targets , navigationMap ) ;
92
+ this . marks = this . extractTargetedDecorations ( targets , navigationMap ) ;
93
+ this . thatMark = thatMark . map ( ( mark ) => serializeSelection ( mark . selection ) ) ;
82
94
this . targets = targets ;
83
95
}
84
96
@@ -123,7 +135,7 @@ export default class TestCase {
123
135
return targetedDecorations ;
124
136
}
125
137
126
- static async getSnapshot ( ) : Promise < Snapshot > {
138
+ static async getSnapshot ( ) : Promise < TestCaseSnapshot > {
127
139
const activeEditor = vscode . window . activeTextEditor ! ;
128
140
return {
129
141
document : activeEditor . document . getText ( ) ,
@@ -159,7 +171,8 @@ export default class TestCase {
159
171
command : this . command ,
160
172
languageId : this . languageId ,
161
173
targets : this . targets ,
162
- decorations : this . decorations ,
174
+ marks : this . marks ,
175
+ thatMark : this . thatMark ,
163
176
initialState : this . initialState ,
164
177
finalState : this . finalState ,
165
178
} ;
0 commit comments