@@ -8,15 +8,15 @@ import { assertFn, checkAdjacentItems } from '../../../../base/common/assert.js'
8
8
import { BugIndicatingError } from '../../../../base/common/errors.js' ;
9
9
import { commonPrefixLength , commonSuffixLength } from '../../../../base/common/strings.js' ;
10
10
import { ISingleEditOperation } from '../editOperation.js' ;
11
- import { StringEdit } from './stringEdit.js' ;
11
+ import { StringEdit , StringReplacement } from './stringEdit.js' ;
12
12
import { Position } from '../position.js' ;
13
13
import { Range } from '../range.js' ;
14
14
import { TextLength } from '../text/textLength.js' ;
15
15
import { AbstractText , StringText } from '../text/abstractText.js' ;
16
16
17
17
export class TextEdit {
18
18
public static fromStringEdit ( edit : StringEdit , initialState : AbstractText ) : TextEdit {
19
- const edits = edit . replacements . map ( e => new TextReplacement ( initialState . getTransformer ( ) . getRange ( e . replaceRange ) , e . newText ) ) ;
19
+ const edits = edit . replacements . map ( e => TextReplacement . fromStringReplacement ( e , initialState ) ) ;
20
20
return new TextEdit ( edits ) ;
21
21
}
22
22
@@ -281,6 +281,10 @@ export class TextReplacement {
281
281
return new TextReplacement ( Range . fromPositions ( startPos , endPos ) , newText ) ;
282
282
}
283
283
284
+ public static fromStringReplacement ( replacement : StringReplacement , initialState : AbstractText ) : TextReplacement {
285
+ return new TextReplacement ( initialState . getTransformer ( ) . getRange ( replacement . replaceRange ) , replacement . newText ) ;
286
+ }
287
+
284
288
constructor (
285
289
public readonly range : Range ,
286
290
public readonly text : string ,
0 commit comments