11using Microsoft ;
2+ using Microsoft . VisualStudio ;
3+ using Microsoft . VisualStudio . Shell ;
24using Microsoft . VisualStudio . Shell . Interop ;
35using System ;
46using System . IO ;
7+ using static Kool . VsDiff . VsDiffPackage ;
58
69namespace Kool . VsDiff . Models
710{
811 internal class VsDiffTool : IDiffTool
912 {
1013 private readonly IVsDifferenceService _diffService ;
1114
12- public VsDiffTool ( VsDiffPackage package )
15+ public VsDiffTool ( )
1316 {
14- var sp = package as IServiceProvider ;
17+ var sp = Instance as IServiceProvider ;
1518 _diffService = ( IVsDifferenceService ) sp . GetService ( typeof ( SVsDifferenceService ) ) ;
1619 Assumes . Present ( _diffService ) ;
1720 }
@@ -23,7 +26,17 @@ public void Diff(string file1, string file2, Action<string, string> callback)
2326 var caption = $ "{ name1 } vs { name2 } ";
2427 var tooltip = file1 + Environment . NewLine + file2 ;
2528
26- _diffService . OpenComparisonWindow2 ( file1 , file2 , caption , tooltip , file1 , file2 , null , null , 0 ) . Show ( ) ;
29+ if ( Options . PreferToUsePreviewWindow )
30+ {
31+ using ( new NewDocumentStateScope ( __VSNEWDOCUMENTSTATE2 . NDS_TryProvisional , VSConstants . NewDocumentStateReason . Navigation ) )
32+ {
33+ _diffService . OpenComparisonWindow2 ( file1 , file2 , caption , tooltip , file1 , file2 , null , null , 0 ) . Show ( ) ;
34+ }
35+ }
36+ else
37+ {
38+ _diffService . OpenComparisonWindow2 ( file1 , file2 , caption , tooltip , file1 , file2 , null , null , 0 ) . Show ( ) ;
39+ }
2740
2841 callback ? . Invoke ( file1 , file2 ) ;
2942 }
0 commit comments