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 ;
21using System . IO ;
3-
42using Avalonia . Data . Converters ;
53
64namespace SourceGit . Converters
@@ -14,17 +12,6 @@ public static class PathConverters
1412 new ( v => Path . GetDirectoryName ( v ) ?? "" ) ;
1513
1614 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 ) ;
2916 }
3017}
Original file line number Diff line number Diff line change @@ -229,6 +229,19 @@ public static string GetAbsPath(string root, string sub)
229229 return fullpath ;
230230 }
231231
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+
232245 private static void UpdateGitVersion ( )
233246 {
234247 if ( string . IsNullOrEmpty ( _gitExecutable ) || ! File . Exists ( _gitExecutable ) )
You can’t perform that action at this time.
0 commit comments