11using System ;
22using System . Collections . Generic ;
33using System . Globalization ;
4-
4+ using System . Threading . Tasks ;
55using Avalonia ;
66using Avalonia . Controls ;
77using Avalonia . Input ;
88using Avalonia . Interactivity ;
99using Avalonia . Media ;
10-
10+ using Avalonia . Threading ;
1111using AvaloniaEdit ;
1212using AvaloniaEdit . Document ;
1313using AvaloniaEdit . Editing ;
@@ -162,7 +162,8 @@ protected override void OnPointerMoved(PointerEventArgs e)
162162 break ;
163163
164164 var info = _editor . BlameData . LineInfos [ lineNumber - 1 ] ;
165- var y = line . GetTextLineVisualYPosition ( line . TextLines [ 0 ] , VisualYPosition . TextTop ) - view . VerticalOffset ;
165+ var y = line . GetTextLineVisualYPosition ( line . TextLines [ 0 ] , VisualYPosition . TextTop )
166+ - view . VerticalOffset ;
166167 var shaLink = new FormattedText (
167168 info . CommitSHA ,
168169 CultureInfo . CurrentCulture ,
@@ -175,12 +176,38 @@ protected override void OnPointerMoved(PointerEventArgs e)
175176 if ( rect . Contains ( pos ) )
176177 {
177178 Cursor = Cursor . Parse ( "Hand" ) ;
179+
180+ // check if the tooltip is already set
181+ var tooltip = ToolTip . GetTip ( this ) ;
182+ if ( tooltip is Models . Commit existedCommit && existedCommit . SHA == info . CommitSHA )
183+ return ;
184+
185+ if ( DataContext is ViewModels . Blame blame )
186+ {
187+ Task . Run ( ( ) =>
188+ {
189+ var commit = blame . GetCommitInfo ( info . CommitSHA ) ;
190+ if ( commit == null )
191+ return ;
192+
193+ Dispatcher . UIThread . Invoke ( ( ) =>
194+ {
195+ if ( IsEffectivelyVisible && IsPointerOver )
196+ {
197+ ToolTip . SetTip ( this , commit ) ;
198+ ToolTip . SetIsOpen ( this , true ) ;
199+ }
200+ } ) ;
201+ } ) ;
202+ }
203+
178204 return ;
179205 }
180206 }
181- }
182207
183- Cursor = Cursor . Default ;
208+ Cursor = Cursor . Default ;
209+ ToolTip . SetIsOpen ( this , false ) ;
210+ }
184211 }
185212
186213 protected override void OnPointerPressed ( PointerPressedEventArgs e )
@@ -230,9 +257,9 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
230257 private readonly BlameTextEditor _editor = null ;
231258 }
232259
233- public class VerticalSeperatorMargin : AbstractMargin
260+ public class VerticalSeparatorMargin : AbstractMargin
234261 {
235- public VerticalSeperatorMargin ( BlameTextEditor editor )
262+ public VerticalSeparatorMargin ( BlameTextEditor editor )
236263 {
237264 _editor = editor ;
238265 }
@@ -284,9 +311,9 @@ public int TabWidth
284311 _textMate = Models . TextMateHelper . CreateForEditor ( this ) ;
285312
286313 TextArea . LeftMargins . Add ( new LineNumberMargin ( ) { Margin = new Thickness ( 8 , 0 ) } ) ;
287- TextArea . LeftMargins . Add ( new VerticalSeperatorMargin ( this ) ) ;
314+ TextArea . LeftMargins . Add ( new VerticalSeparatorMargin ( this ) ) ;
288315 TextArea . LeftMargins . Add ( new CommitInfoMargin ( this ) { Margin = new Thickness ( 8 , 0 ) } ) ;
289- TextArea . LeftMargins . Add ( new VerticalSeperatorMargin ( this ) ) ;
316+ TextArea . LeftMargins . Add ( new VerticalSeparatorMargin ( this ) ) ;
290317 TextArea . Caret . PositionChanged += OnTextAreaCaretPositionChanged ;
291318 TextArea . LayoutUpdated += OnTextAreaLayoutUpdated ;
292319 TextArea . PointerWheelChanged += OnTextAreaPointerWheelChanged ;
0 commit comments