提交 4d0d69ae 编写于 作者: A Andrew Casey

Merge pull request #5150 from amcasey/AutonomousFind

Use the new Find LaF in Interactive
......@@ -7,7 +7,6 @@
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.OLE.Interop;
......@@ -15,7 +14,6 @@
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.InteractiveWindow;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.InteractiveWindow.Shell
......@@ -32,8 +30,11 @@ namespace Microsoft.VisualStudio.InteractiveWindow.Shell
/// on the interactive window.
/// </summary>
[Guid(Guids.InteractiveToolWindowIdString)]
internal sealed class VsInteractiveWindow : ToolWindowPane, IVsFindTarget, IOleCommandTarget, IVsInteractiveWindow
internal sealed class VsInteractiveWindow : ToolWindowPane, IOleCommandTarget, IVsInteractiveWindow
{
// Keep in sync with Microsoft.VisualStudio.Editor.Implementation.EnableFindOptionDefinition.OptionName.
private const string EnableFindOptionName = "Enable Autonomous Find";
private readonly IComponentModel _componentModel;
private readonly IVsEditorAdaptersFactoryService _editorAdapters;
......@@ -93,7 +94,9 @@ protected override void OnCreate()
_window = _componentModel.GetService<IInteractiveWindowFactoryService>().CreateWindow(_evaluator);
_window.SubmissionBufferAdded += SubmissionBufferAdded;
_textViewHost = _window.GetTextViewHost();
var viewAdapter = _editorAdapters.GetViewAdapter(_textViewHost.TextView);
var textView = _textViewHost.TextView;
textView.Options.SetOptionValue(EnableFindOptionName, true);
var viewAdapter = _editorAdapters.GetViewAdapter(textView);
_findTarget = viewAdapter as IVsFindTarget;
_commandTarget = viewAdapter as IOleCommandTarget;
}
......@@ -187,122 +190,5 @@ private IVsToolWindowToolbarHost GetToolbarHost()
}
#endregion
#region IVsFindTarget
public int Find(string pszSearch, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out uint pResult)
{
if (_findTarget != null)
{
return _findTarget.Find(pszSearch, grfOptions, fResetStartPoint, pHelper, out pResult);
}
pResult = 0;
return VSConstants.E_NOTIMPL;
}
public int GetCapabilities(bool[] pfImage, uint[] pgrfOptions)
{
if (_findTarget != null && pgrfOptions != null && pgrfOptions.Length > 0)
{
return _findTarget.GetCapabilities(pfImage, pgrfOptions);
}
return VSConstants.E_NOTIMPL;
}
public int GetCurrentSpan(TextSpan[] pts)
{
if (_findTarget != null)
{
return _findTarget.GetCurrentSpan(pts);
}
return VSConstants.E_NOTIMPL;
}
public int GetFindState(out object ppunk)
{
if (_findTarget != null)
{
return _findTarget.GetFindState(out ppunk);
}
ppunk = null;
return VSConstants.E_NOTIMPL;
}
public int GetMatchRect(RECT[] prc)
{
if (_findTarget != null)
{
return _findTarget.GetMatchRect(prc);
}
return VSConstants.E_NOTIMPL;
}
public int GetProperty(uint propid, out object pvar)
{
if (_findTarget != null)
{
return _findTarget.GetProperty(propid, out pvar);
}
pvar = null;
return VSConstants.E_NOTIMPL;
}
public int GetSearchImage(uint grfOptions, IVsTextSpanSet[] ppSpans, out IVsTextImage ppTextImage)
{
if (_findTarget != null)
{
return _findTarget.GetSearchImage(grfOptions, ppSpans, out ppTextImage);
}
ppTextImage = null;
return VSConstants.E_NOTIMPL;
}
public int MarkSpan(TextSpan[] pts)
{
if (_findTarget != null)
{
return _findTarget.MarkSpan(pts);
}
return VSConstants.E_NOTIMPL;
}
public int NavigateTo(TextSpan[] pts)
{
if (_findTarget != null)
{
return _findTarget.NavigateTo(pts);
}
return VSConstants.E_NOTIMPL;
}
public int NotifyFindTarget(uint notification)
{
if (_findTarget != null)
{
return _findTarget.NotifyFindTarget(notification);
}
return VSConstants.E_NOTIMPL;
}
public int Replace(string pszSearch, string pszReplace, uint grfOptions, int fResetStartPoint, IVsFindHelper pHelper, out int pfReplaced)
{
if (_findTarget != null)
{
return _findTarget.Replace(pszSearch, pszReplace, grfOptions, fResetStartPoint, pHelper, out pfReplaced);
}
pfReplaced = 0;
return VSConstants.E_NOTIMPL;
}
public int SetFindState(object pUnk)
{
if (_findTarget != null)
{
return _findTarget.SetFindState(pUnk);
}
return VSConstants.E_NOTIMPL;
}
#endregion
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册