@@ -95,12 +95,6 @@ private Microsoft.VisualStudio.Shell.Package GetProjectSystemPackage()
9595return this . projectSystemPackage ;
9696}
9797
98- private bool DebuggerIsRunning ( )
99- {
100- var debugger = this . service . GetIVsDebugger ( ) ;
101- return debugger != null && this . mgr . LanguageService . IsDebugging ;
102- }
103-
10498private bool EditorSelectionIsEmpty ( )
10599{
106100string selection ;
@@ -222,16 +216,16 @@ public IVsTextView TextView {
222216get { return this . textView ; }
223217}
224218
225- /// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ViewFilter.IsExpansionUIActive"]/*' />
226- public virtual bool IsExpansionUIActive {
227- get {
228- IVsTextViewEx tve = this . textView as IVsTextViewEx ;
229- if ( tve != null && tve . IsExpansionUIActive ( ) == VSConstants . S_OK ) {
230- return true ;
231- }
232- return false ;
233- }
234- }
219+ /// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ViewFilter.IsExpansionUIActive"]/*' />
220+ public virtual bool IsExpansionUIActive {
221+ get {
222+ IVsTextViewEx tve = this . textView as IVsTextViewEx ;
223+ if ( tve != null && tve . IsExpansionUIActive ( ) == VSConstants . S_OK ) {
224+ return true ;
225+ }
226+ return false ;
227+ }
228+ }
235229
236230 #region IVsTextViewFilter methods
237231/// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.GetWordExtent"]/*' />
@@ -362,76 +356,86 @@ public virtual void OnSetFocus(IVsTextView view) {
362356/// OLECMDF_ENABLED | OLECMDF_SUPPORTED.
363357/// Return E_FAIL if want to delegate to the next command target.
364358/// </returns>
365- protected virtual int QueryCommandStatus ( ref Guid guidCmdGroup , uint nCmdId ) {
359+ protected virtual int QueryCommandStatus ( ref Guid guidCmdGroup , uint nCmdId )
360+ {
366361ExpansionProvider ep = GetExpansionProvider ( ) ;
367- if ( ep != null && ep . InTemplateEditingMode ) {
362+ if ( ep != null && ep . InTemplateEditingMode )
363+ {
368364int hr = 0 ;
369365if ( ep . HandleQueryStatus ( ref guidCmdGroup , nCmdId , out hr ) )
370366return hr ;
371367}
372- if ( guidCmdGroup == typeof ( VsCommands ) . GUID ) {
368+ if ( guidCmdGroup == typeof ( VsCommands ) . GUID )
369+ {
373370VsCommands cmd = ( VsCommands ) nCmdId ;
374371
375- switch ( cmd ) {
376- case VsCommands . GotoDefn :
377- case VsCommands . GotoDecl :
378- case VsCommands . GotoRef :
379- case VsCommands . Goto :
380- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
372+ switch ( cmd )
373+ {
374+ case VsCommands . GotoDefn :
375+ case VsCommands . GotoDecl :
376+ case VsCommands . GotoRef :
377+ case VsCommands . Goto :
378+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
381379}
382- } else if ( guidCmdGroup == typeof ( VsCommands2K ) . GUID ) {
380+ }
381+ else if ( guidCmdGroup == typeof ( VsCommands2K ) . GUID )
382+ {
383383VsCommands2K cmd = ( VsCommands2K ) nCmdId ;
384384
385- switch ( cmd ) {
386- case VsCommands2K . FORMATDOCUMENT :
387- if ( this . CanReformat ( ) )
388- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
389- break ;
390- case VsCommands2K . FORMATSELECTION :
391- if ( this . CanReformat ( ) )
392- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
393- break ;
385+ switch ( cmd )
386+ {
387+ case VsCommands2K . FORMATDOCUMENT :
388+ if ( this . CanReformat ( ) )
389+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
390+ break ;
391+ case VsCommands2K . FORMATSELECTION :
392+ if ( this . CanReformat ( ) )
393+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
394+ break ;
394395
395- case VsCommands2K . COMMENT_BLOCK :
396- case VsCommands2K . UNCOMMENT_BLOCK :
397- if ( this . commentSupported )
398- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
399- break ;
396+ case VsCommands2K . COMMENT_BLOCK :
397+ case VsCommands2K . UNCOMMENT_BLOCK :
398+ if ( this . commentSupported )
399+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
400+ break ;
400401
401- case VsCommands2K . SHOWMEMBERLIST :
402- case VsCommands2K . COMPLETEWORD :
403- case VsCommands2K . PARAMINFO :
402+ case VsCommands2K . SHOWMEMBERLIST :
403+ case VsCommands2K . COMPLETEWORD :
404+ case VsCommands2K . PARAMINFO :
405+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
406+
407+ case VsCommands2K . QUICKINFO :
408+ if ( this . service . Preferences . EnableQuickInfo )
409+ {
404410return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
411+ }
412+ break ;
405413
406- case VsCommands2K . QUICKINFO :
407- if ( this . service . Preferences . EnableQuickInfo ) {
408- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
409- }
410- break ;
414+ // case VsCommands2K.HANDLEIMEMESSAGE:
415+ // return 0;
411416
412- // case VsCommands2K.HANDLEIMEMESSAGE:
413- // return 0;
414-
415- // Let the core editor handle this. Stop outlining also removes user
416- // defined hidden sections so it is handy to keep this enabled.
417- // case VsCommands2K.OUTLN_STOP_HIDING_ALL:
418- // int rc = (int)OLECMDF.OLECMDF_SUPPORTED;
419- // if (this.source.OutliningEnabled) {
420- // rc |= (int)OLECMDF.OLECMDF_ENABLED;
421- // }
422- // return rc;
417+ // Let the core editor handle this. Stop outlining also removes user
418+ // defined hidden sections so it is handy to keep this enabled.
419+ // case VsCommands2K.OUTLN_STOP_HIDING_ALL:
420+ // int rc = (int)OLECMDF.OLECMDF_SUPPORTED;
421+ // if (this.source.OutliningEnabled) {
422+ // rc |= (int)OLECMDF.OLECMDF_ENABLED;
423+ // }
424+ // return rc;
423425
424- case VsCommands2K . OUTLN_START_AUTOHIDING :
425- if ( this . source . OutliningEnabled ) {
426- return ( int ) OleConstants . OLECMDERR_E_NOTSUPPORTED ;
427- }
428- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
429-
430- case VsCommands2K . OUTLN_STOP_HIDING_ALL : //"stop outlining" on context menu
431- if ( this . source . OutliningEnabled ) {
432- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
433- }
426+ case VsCommands2K . OUTLN_START_AUTOHIDING :
427+ if ( this . source . OutliningEnabled )
428+ {
434429return ( int ) OleConstants . OLECMDERR_E_NOTSUPPORTED ;
430+ }
431+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
432+
433+ case VsCommands2K . OUTLN_STOP_HIDING_ALL : //"stop outlining" on context menu
434+ if ( this . source . OutliningEnabled )
435+ {
436+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
437+ }
438+ return ( int ) OleConstants . OLECMDERR_E_NOTSUPPORTED ;
435439}
436440}
437441else if ( guidCmdGroup == Microsoft . VisualStudio . VSConstants . VsStd11 )
@@ -445,19 +449,21 @@ protected virtual int QueryCommandStatus(ref Guid guidCmdGroup, uint nCmdId) {
445449{
446450if ( nCmdId == cmdIDDebugSelection )
447451{
448- if ( DebuggerIsRunning ( ) )
452+ var dbgState = Interactive . Hooks . GetDebuggerState ( GetProjectSystemPackage ( ) ) ;
453+
454+ if ( dbgState == Interactive . FsiDebuggerState . AttachedNotToFSI )
449455return ( int ) OLECMDF . OLECMDF_INVISIBLE ;
456+ else if ( EditorSelectionIsEmpty ( ) )
457+ return ( int ) OLECMDF . OLECMDF_SUPPORTED ;
450458else
451- {
452- if ( EditorSelectionIsEmpty ( ) )
453- return ( int ) OLECMDF . OLECMDF_SUPPORTED ;
454- else
455- return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
456- }
459+ return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
457460}
461+
458462else if ( nCmdId == cmdIDDebugLine )
459463{
460- if ( DebuggerIsRunning ( ) )
464+ var dbgState = Interactive . Hooks . GetDebuggerState ( GetProjectSystemPackage ( ) ) ;
465+
466+ if ( dbgState == Interactive . FsiDebuggerState . AttachedNotToFSI )
461467return ( int ) OLECMDF . OLECMDF_INVISIBLE ;
462468else
463469return ( int ) OLECMDF . OLECMDF_SUPPORTED | ( int ) OLECMDF . OLECMDF_ENABLED ;
@@ -584,20 +590,15 @@ public virtual bool HandlePreExec(ref Guid guidCmdGroup, uint nCmdId, uint nCmde
584590{
585591if ( nCmdId == ( uint ) Microsoft . VisualStudio . VSConstants . VSStd11CmdID . ExecuteSelectionInInteractive )
586592{
587- Microsoft . VisualStudio . FSharp . Interactive . Hooks . OnMLSend ( GetProjectSystemPackage ( ) , null , null ) ;
593+ Interactive . Hooks . OnMLSend ( GetProjectSystemPackage ( ) , false , null , null ) ;
588594return true ;
589595}
590596}
591597else if ( guidCmdGroup == guidInteractive )
592598{
593599if ( nCmdId == cmdIDDebugSelection )
594600{
595- Interactive . Hooks . OnMLSend ( GetProjectSystemPackage ( ) , false , true , null , null ) ;
596- return true ;
597- }
598- else if ( nCmdId == cmdIDDebugLine )
599- {
600- Interactive . Hooks . OnMLSend ( GetProjectSystemPackage ( ) , true , true , null , null ) ;
601+ Interactive . Hooks . OnMLSend ( GetProjectSystemPackage ( ) , true , null , null ) ;
601602return true ;
602603}
603604}