@@ -41,7 +41,7 @@ public async Task<RangeOrPlaceholderRange> Handle(PrepareRenameParams request, C
41
41
if ( token is null ) { return null ; }
42
42
43
43
// TODO: Really should have a class with implicit convertors handing these conversions to avoid off-by-one mistakes.
44
- return Utilities . ToRange ( token . Extent ) ; ;
44
+ return new ScriptExtentAdapter ( token . Extent ) ;
45
45
}
46
46
47
47
/// <summary>
@@ -211,7 +211,6 @@ public ScriptPositionAdapter(Position position) : this(position.Line + 1, positi
211
211
public static implicit operator ScriptPositionAdapter ( ScriptPosition position ) => new ( position ) ;
212
212
213
213
public static implicit operator Position ( ScriptPositionAdapter scriptPosition ) => new ( scriptPosition . position . LineNumber - 1 , scriptPosition . position . ColumnNumber - 1 ) ;
214
-
215
214
public static implicit operator ScriptPosition ( ScriptPositionAdapter position ) => position ;
216
215
217
216
internal ScriptPositionAdapter Delta ( int LineAdjust , int ColumnAdjust ) => new (
@@ -242,26 +241,20 @@ internal record ScriptExtentAdapter(IScriptExtent extent) : IScriptExtent
242
241
public ScriptPositionAdapter End = new ( extent . EndScriptPosition ) ;
243
242
244
243
public static implicit operator ScriptExtentAdapter ( ScriptExtent extent ) => new ( extent ) ;
245
- public static implicit operator ScriptExtent ( ScriptExtentAdapter extent ) => extent ;
246
-
247
- public static implicit operator Range ( ScriptExtentAdapter extent ) => new ( )
248
- {
249
- Start = extent . Start ,
250
- End = extent . End
251
- // End = extent.End with
252
- // {
253
- // // The end position in Script Extents is actually shifted an additional 1 column, no idea why
254
- // // https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.language.iscriptextent.endscriptposition?view=powershellsdk-7.4.0#system-management-automation-language-iscriptextent-endscriptposition
255
-
256
- // position = (extent.EndScriptPosition as ScriptPositionAdapter).Delta(0, -1)
257
- // }
258
- } ;
259
244
public static implicit operator ScriptExtentAdapter ( Range range ) => new ( new ScriptExtent (
260
245
// Will get shifted to 1-based
261
246
new ScriptPositionAdapter ( range . Start ) ,
262
247
new ScriptPositionAdapter ( range . End )
263
248
) ) ;
264
249
250
+ public static implicit operator ScriptExtent ( ScriptExtentAdapter adapter ) => adapter ;
251
+ public static implicit operator Range ( ScriptExtentAdapter adapter ) => new ( )
252
+ {
253
+ Start = adapter . Start ,
254
+ End = adapter . End
255
+ } ;
256
+ public static implicit operator RangeOrPlaceholderRange ( ScriptExtentAdapter adapter ) => new ( adapter ) ;
257
+
265
258
public IScriptPosition StartScriptPosition => Start ;
266
259
public IScriptPosition EndScriptPosition => End ;
267
260
public int EndColumnNumber => End . ColumnNumber ;
0 commit comments