33using GitHub . VisualStudio ;
44using GitHub . Services . Vssdk . Commands ;
55using System . ComponentModel . Composition ;
6+ using Microsoft . VisualStudio . TextManager . Interop ;
7+ using Microsoft . VisualStudio ;
8+ using Microsoft . VisualStudio . Editor ;
9+ using GitHub . Services ;
610
711namespace GitHub . InlineReviews . Commands
812{
@@ -19,13 +23,31 @@ public class EnableInlineCommentsCommand : VsCommand, IEnableInlineCommentsComma
1923 /// </summary>
2024 public const int CommandId = PkgCmdIDList . EnableInlineCommentsId ;
2125
22- public EnableInlineCommentsCommand ( ) : base ( CommandSet , CommandId )
26+ const string optionName = "TextViewHost/GlyphMargin" ;
27+
28+ readonly Lazy < IVsTextManager > textManager ;
29+ readonly Lazy < IVsEditorAdaptersFactoryService > editorAdapter ;
30+
31+ [ ImportingConstructor ]
32+ public EnableInlineCommentsCommand (
33+ IGitHubServiceProvider serviceProvider ,
34+ Lazy < IVsEditorAdaptersFactoryService > editorAdapter ) : base ( CommandSet , CommandId )
2335 {
36+ textManager = new Lazy < IVsTextManager > ( ( ) => serviceProvider . GetService < SVsTextManager , IVsTextManager > ( ) ) ;
37+ this . editorAdapter = editorAdapter ;
2438 }
2539
2640 public override Task Execute ( )
2741 {
28- System . Diagnostics . Trace . WriteLine ( "EnableInlineComments" ) ;
42+ IVsTextView activeView = null ;
43+ if ( textManager . Value . GetActiveView ( 1 , null , out activeView ) == VSConstants . S_OK )
44+ {
45+ var wpfTextView = editorAdapter . Value . GetWpfTextView ( activeView ) ;
46+ var options = wpfTextView . Options ;
47+ var enabled = options . GetOptionValue < bool > ( optionName ) ;
48+ options . SetOptionValue ( optionName , ! enabled ) ;
49+ }
50+
2951 return Task . CompletedTask ;
3052 }
3153 }
0 commit comments