@@ -9,7 +9,6 @@ type ExportedLatexSelection = {
9
9
startIndex : number ;
10
10
endIndex : number ;
11
11
opaqueSnapshot : {
12
- uncleanedLatex : string ;
13
12
cursorInsertPath : string ;
14
13
signedSelectionSize : number ;
15
14
} ;
@@ -192,14 +191,20 @@ class Controller_latex extends Controller_keystroke {
192
191
}
193
192
194
193
restoreLatexSelection ( data : ExportedLatexSelection ) {
195
- const currentUncleanedLatex =
196
- this . exportLatexSelection ( ) . opaqueSnapshot . uncleanedLatex ;
197
- const { cursorInsertPath, signedSelectionSize, uncleanedLatex } =
198
- data . opaqueSnapshot ;
199
-
200
- // verify the uncleanedLatex are identical. We need the trees to be identical so that the
201
- // path instructions are relative to an identical tree structure
202
- if ( currentUncleanedLatex !== uncleanedLatex ) return ;
194
+ const currentSelectionInfo = this . exportLatexSelection ( ) ;
195
+ const currentLatex = currentSelectionInfo . selection . latex ;
196
+ const newLatex = data . latex ;
197
+ const { cursorInsertPath, signedSelectionSize } = data . opaqueSnapshot ;
198
+
199
+ // latex's must match for the indicies in the selection to match up
200
+ if ( currentLatex !== newLatex ) return ;
201
+
202
+ // TODO - track things better so that we can actually make this work
203
+ if ( currentLatex !== currentSelectionInfo . ctx . latex ) {
204
+ throw new Error (
205
+ 'TODO - restoring selection requires uncleanedLatex to match latex'
206
+ ) ;
207
+ }
203
208
204
209
if ( ! this . insertCursorAtPath ( cursorInsertPath ) ) return ;
205
210
@@ -238,7 +243,10 @@ class Controller_latex extends Controller_keystroke {
238
243
return count ;
239
244
}
240
245
241
- exportLatexSelection ( ) : ExportedLatexSelection {
246
+ exportLatexSelection ( ) : {
247
+ selection : ExportedLatexSelection ;
248
+ ctx : LatexContext ;
249
+ } {
242
250
var ctx : LatexContext = {
243
251
latex : '' ,
244
252
startIndex : - 1 ,
@@ -305,14 +313,16 @@ class Controller_latex extends Controller_keystroke {
305
313
}
306
314
307
315
return {
308
- latex : cleanLatex ,
309
- startIndex : startIndex ,
310
- endIndex : endIndex ,
311
- opaqueSnapshot : {
312
- uncleanedLatex,
313
- cursorInsertPath,
314
- signedSelectionSize
315
- }
316
+ selection : {
317
+ latex : cleanLatex ,
318
+ startIndex : startIndex ,
319
+ endIndex : endIndex ,
320
+ opaqueSnapshot : {
321
+ cursorInsertPath,
322
+ signedSelectionSize
323
+ }
324
+ } ,
325
+ ctx
316
326
} ;
317
327
}
318
328
0 commit comments