File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change 1
- using System ;
2
1
using System . IO ;
3
-
4
2
using Avalonia . Data . Converters ;
5
3
6
4
namespace SourceGit . Converters
@@ -14,17 +12,6 @@ public static class PathConverters
14
12
new ( v => Path . GetDirectoryName ( v ) ?? "" ) ;
15
13
16
14
public static readonly FuncValueConverter < string , string > RelativeToHome =
17
- new ( v =>
18
- {
19
- if ( OperatingSystem . IsWindows ( ) )
20
- return v ;
21
-
22
- var home = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ;
23
- var prefixLen = home . EndsWith ( '/' ) ? home . Length - 1 : home . Length ;
24
- if ( v . StartsWith ( home , StringComparison . Ordinal ) )
25
- return $ "~{ v . AsSpan ( prefixLen ) } ";
26
-
27
- return v ;
28
- } ) ;
15
+ new ( Native . OS . GetRelativePathToHome ) ;
29
16
}
30
17
}
Original file line number Diff line number Diff line change @@ -229,6 +229,19 @@ public static string GetAbsPath(string root, string sub)
229
229
return fullpath ;
230
230
}
231
231
232
+ public static string GetRelativePathToHome ( string path )
233
+ {
234
+ if ( OperatingSystem . IsWindows ( ) )
235
+ return path ;
236
+
237
+ var home = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) ;
238
+ var prefixLen = home . EndsWith ( '/' ) ? home . Length - 1 : home . Length ;
239
+ if ( path . StartsWith ( home , StringComparison . Ordinal ) )
240
+ return $ "~{ path . AsSpan ( prefixLen ) } ";
241
+
242
+ return path ;
243
+ }
244
+
232
245
private static void UpdateGitVersion ( )
233
246
{
234
247
if ( string . IsNullOrEmpty ( _gitExecutable ) || ! File . Exists ( _gitExecutable ) )
You can’t perform that action at this time.
0 commit comments