diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml
index 10385f9702713d3bc54bd4ade39d67c2920dca49..89bed49d14ad952e4302d9b416af7263613ae1a0 100644
--- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml
+++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml
@@ -42,15 +42,15 @@
-
+
-
+
-
internal class IntellisenseTextBox : FrameworkElement, IOleCommandTarget
{
- ///
- /// Contains the text in the buffer
- ///
- private readonly IVsTextLines _vsTextLines;
-
///
/// IWpfTextView container
///
@@ -55,11 +50,9 @@ internal class IntellisenseTextBox : FrameworkElement, IOleCommandTarget
///
/// Initializes a new instance of the class.
///
- public IntellisenseTextBox(
- IVsTextLines vsTextLines, IVsTextView vsTextView, IWpfTextView wpfTextView, ContentControl container)
+ public IntellisenseTextBox(IntellisenseTextBoxViewModel viewModel, ContentControl container)
{
- this._vsTextLines = vsTextLines;
- this.InitializeEditorControl(vsTextView, wpfTextView, container);
+ this.InitializeEditorControl(viewModel, container);
}
///
@@ -91,15 +84,7 @@ public bool HasActiveIntellisenseSession
///
public string Text
{
- get
- {
- int length;
- string text;
- // TODO why 0?
- this._vsTextLines.GetLengthOfLine(0, out length);
- this._vsTextLines.GetLineText(0, 0, 0, length, out text);
- return text;
- }
+ get => this._textViewHost.TextView.TextSnapshot.GetText();
}
/////
@@ -107,10 +92,7 @@ public string Text
/////
protected override int VisualChildrenCount
{
- get
- {
- return 1;
- }
+ get => 1;
}
///
@@ -275,15 +257,12 @@ protected override void OnGotFocus(RoutedEventArgs e)
///
/// Initializes the editor control
///
- private void InitializeEditorControl(IVsTextView vsTextView, IWpfTextView wpfTextView, ContentControl container)
+ private void InitializeEditorControl(IntellisenseTextBoxViewModel viewModel, ContentControl container)
{
IComponentModel componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
- // TODO Set text buffer initial contents
- // ErrorHandler.ThrowOnFailure(vsTextBuffer.InitializeContent(initialContent, initialContent != null ? initialContent.Length : 0));
-
// Sets editor options that control its final look
- IEditorOptions editorOptions = wpfTextView.Properties.GetProperty(typeof(IEditorOptions)) as IEditorOptions;
+ IEditorOptions editorOptions = viewModel.WpfTextView.Properties.GetProperty(typeof(IEditorOptions)) as IEditorOptions;
editorOptions.SetOptionValue("TextViewHost/ZoomControl", false);
editorOptions.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, appearanceCategory);
@@ -301,14 +280,14 @@ private void InitializeEditorControl(IVsTextView vsTextView, IWpfTextView wpfTex
IEditorOperationsFactoryService editorOperationsFactoryService = componentModel.GetService();
if (editorOperationsFactoryService != null)
{
- this._editorOperations = editorOperationsFactoryService.GetEditorOperations(wpfTextView);
+ this._editorOperations = editorOperationsFactoryService.GetEditorOperations(viewModel.WpfTextView);
}
- ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out this._nextCommandTarget));
+ ErrorHandler.ThrowOnFailure(viewModel.VsTextView.AddCommandFilter(this, out this._nextCommandTarget));
// Get the host control to render the view
IVsEditorAdaptersFactoryService editorAdapterFactory = componentModel.GetService();
- this._textViewHost = editorAdapterFactory.GetWpfTextViewHost(vsTextView);
+ this._textViewHost = editorAdapterFactory.GetWpfTextViewHost(viewModel.VsTextView);
// For non-blurry text
TextOptions.SetTextFormattingMode(this._textViewHost.HostControl, TextFormattingMode.Display);
diff --git a/src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBoxViewModel.cs b/src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBoxViewModel.cs
new file mode 100644
index 0000000000000000000000000000000000000000..4addba75c96194000a7ac6847bb56cb81ff10907
--- /dev/null
+++ b/src/VisualStudio/Core/Def/Implementation/Utilities/IntellisenseTextBoxViewModel.cs
@@ -0,0 +1,18 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Microsoft.VisualStudio.LanguageServices.Implementation
+{
+ internal readonly struct IntellisenseTextBoxViewModel
+ {
+ public readonly IVsTextView VsTextView;
+ public readonly IWpfTextView WpfTextView;
+ public IntellisenseTextBoxViewModel(IVsTextView vsTextView, IWpfTextView wpfTextView)
+ {
+ VsTextView = vsTextView;
+ WpfTextView = wpfTextView;
+ }
+ }
+}