@@ -126,7 +126,7 @@ public override void Render(DrawingContext context)
126126 typeface ,
127127 presenter . FontSize ,
128128 presenter . Foreground ) ;
129- context . DrawText ( txt , new Point ( Bounds . Width - txt . Width , y - txt . Height * 0.5 ) ) ;
129+ context . DrawText ( txt , new Point ( Bounds . Width - txt . Width , y - ( txt . Height * 0.5 ) ) ) ;
130130 }
131131 }
132132 }
@@ -212,7 +212,7 @@ public override void Render(DrawingContext context)
212212 }
213213
214214 if ( indicator != null )
215- context . DrawText ( indicator , new Point ( 0 , y - indicator . Height * 0.5 ) ) ;
215+ context . DrawText ( indicator , new Point ( 0 , y - ( indicator . Height * 0.5 ) ) ) ;
216216 }
217217 }
218218 }
@@ -1047,7 +1047,8 @@ private void CopyWithoutIndicators()
10471047 // The first selected line (partial selection)
10481048 if ( i == startIdx && startPosition . Column > 1 )
10491049 {
1050- builder . AppendLine ( line . Content . Substring ( startPosition . Column - 1 ) ) ;
1050+ builder . Append ( line . Content . AsSpan ( ) . Slice ( startPosition . Column - 1 ) ) ;
1051+ builder . Append ( Environment . NewLine ) ;
10511052 continue ;
10521053 }
10531054
@@ -1061,7 +1062,14 @@ private void CopyWithoutIndicators()
10611062 // For the last line (selection range is within original source)
10621063 if ( i == endIdx )
10631064 {
1064- builder . Append ( endPosition . Column - 1 < line . Content . Length ? line . Content . Substring ( 0 , endPosition . Column - 1 ) : line . Content ) ;
1065+ if ( endPosition . Column - 1 < line . Content . Length )
1066+ {
1067+ builder . Append ( line . Content . AsSpan ( ) . Slice ( 0 , endPosition . Column - 1 ) ) ;
1068+ }
1069+ else
1070+ {
1071+ builder . Append ( line . Content ) ;
1072+ }
10651073 break ;
10661074 }
10671075
@@ -1246,12 +1254,12 @@ protected override void OnDataContextChanged(EventArgs e)
12461254 var textDiff = DataContext as Models . TextDiff ;
12471255 if ( textDiff != null )
12481256 {
1249- var builder = new StringBuilder ( ) ;
1257+ var builder = new StringBuilder ( 512 ) ;
12501258 foreach ( var line in textDiff . Lines )
12511259 {
12521260 if ( line . Content . Length > 10000 )
12531261 {
1254- builder . Append ( line . Content . Substring ( 0 , 1000 ) ) ;
1262+ builder . Append ( line . Content . AsSpan ( ) . Slice ( 0 , 1000 ) ) ;
12551263 builder . Append ( $ "...({ line . Content . Length - 1000 } character trimmed)") ;
12561264 }
12571265 else
@@ -1741,7 +1749,7 @@ static TextDiffView()
17411749 }
17421750
17431751 var top = chunk . Y + ( chunk . Height >= 36 ? 16 : 4 ) ;
1744- var right = ( chunk . Combined || ! chunk . IsOldSide ) ? 16 : v . Bounds . Width * 0.5f + 16 ;
1752+ var right = ( chunk . Combined || ! chunk . IsOldSide ) ? 16 : ( v . Bounds . Width * 0.5f ) + 16 ;
17451753 v . Popup . Margin = new Thickness ( 0 , top , right , 0 ) ;
17461754 v . Popup . IsVisible = true ;
17471755 } ) ;
0 commit comments