Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKirill Osenkov <github@osenkov.com>2018-02-02 03:27:08 +0300
committerKirill Osenkov <github@osenkov.com>2018-02-02 03:27:08 +0300
commiteb99ad1fcdc87617e55a63aa7ce655c6816aa354 (patch)
tree40dc08767558501da2664d24a4b0de53076d77c4 /src
parent75fb4e3a60aacbf6a300d8c235a6463fbe735f4c (diff)
Update to latest version.
Branch: dev/amwieczo/completionIn15.6 Commit: 5a23388e08a84162f174ce74bed886e54fff3953 Version of definitions: 15.8.173-preview-g3a2638b5fc Version of Language.dll: 15.6.289-preview-g5a23388e08
Diffstat (limited to 'src')
-rw-r--r--src/Microsoft.VisualStudio.Text.Implementation.csproj6
-rw-r--r--src/Microsoft.VisualStudio.Text.Implementation.nuspec12
-rw-r--r--src/Text/Impl/EditorOperations/Commands/DuplicateSelectionCommandHandler.cs31
-rw-r--r--src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionCommandHandler.cs68
-rw-r--r--src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionImplementation.cs134
-rw-r--r--src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionOptionDefinitions.cs25
-rw-r--r--src/Text/Impl/EditorOperations/Strings.Designer.cs18
-rw-r--r--src/Text/Impl/EditorOperations/Strings.resx6
8 files changed, 291 insertions, 9 deletions
diff --git a/src/Microsoft.VisualStudio.Text.Implementation.csproj b/src/Microsoft.VisualStudio.Text.Implementation.csproj
index 7e3a87c..7364610 100644
--- a/src/Microsoft.VisualStudio.Text.Implementation.csproj
+++ b/src/Microsoft.VisualStudio.Text.Implementation.csproj
@@ -5,9 +5,9 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
- <Version>15.0.9-pre</Version>
+ <Version>15.0.10-pre</Version>
<AssemblyVersion>15.0.0.0</AssemblyVersion>
- <NuGetVersionEditor>15.6.253-preview</NuGetVersionEditor>
+ <NuGetVersionEditor>15.8.173-preview-g3a2638b5fc</NuGetVersionEditor>
</PropertyGroup>
<PropertyGroup>
@@ -111,7 +111,7 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="System.Collections.Immutable" Version="1.3.1" />
+ <PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
<PackageReference Include="Microsoft.VisualStudio.CoreUtility" Version="$(NuGetVersionEditor)" />
<PackageReference Include="Microsoft.VisualStudio.Language.StandardClassification" Version="$(NuGetVersionEditor)" />
diff --git a/src/Microsoft.VisualStudio.Text.Implementation.nuspec b/src/Microsoft.VisualStudio.Text.Implementation.nuspec
index 9301476..79b2c7d 100644
--- a/src/Microsoft.VisualStudio.Text.Implementation.nuspec
+++ b/src/Microsoft.VisualStudio.Text.Implementation.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Microsoft.VisualStudio.Text.Implementation</id>
- <version>15.0.8-pre</version>
+ <version>15.0.10-pre</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
@@ -13,11 +13,11 @@
<repository url="https://github.com/Microsoft/vs-editor-api" />
<dependencies>
<group targetFramework=".NETFramework4.6">
- <dependency id="Microsoft.VisualStudio.Text.Data" version="15.6.241-preview" exclude="Build,Analyzers" />
- <dependency id="Microsoft.VisualStudio.Text.Logic" version="15.6.241-preview" exclude="Build,Analyzers" />
- <dependency id="Microsoft.VisualStudio.Language.StandardClassification" version="15.6.241-preview" exclude="Build,Analyzers" />
- <dependency id="Microsoft.VisualStudio.CoreUtility" version="15.6.241-preview" exclude="Build,Analyzers" />
- <dependency id="Microsoft.VisualStudio.Text.UI" version="15.6.241-preview" exclude="Build,Analyzers" />
+ <dependency id="Microsoft.VisualStudio.CoreUtility" version="15.8.173-preview-g3a2638b5fc" exclude="Build,Analyzers" />
+ <dependency id="Microsoft.VisualStudio.Language.StandardClassification" version="15.8.173-preview-g3a2638b5fc" exclude="Build,Analyzers" />
+ <dependency id="Microsoft.VisualStudio.Text.Data" version="15.8.173-preview-g3a2638b5fc" exclude="Build,Analyzers" />
+ <dependency id="Microsoft.VisualStudio.Text.Logic" version="15.8.173-preview-g3a2638b5fc" exclude="Build,Analyzers" />
+ <dependency id="Microsoft.VisualStudio.Text.UI" version="15.8.173-preview-g3a2638b5fc" exclude="Build,Analyzers" />
<dependency id="System.Collections.Immutable" version="1.3.1" exclude="Build,Analyzers" />
</group>
</dependencies>
diff --git a/src/Text/Impl/EditorOperations/Commands/DuplicateSelectionCommandHandler.cs b/src/Text/Impl/EditorOperations/Commands/DuplicateSelectionCommandHandler.cs
new file mode 100644
index 0000000..1b6e059
--- /dev/null
+++ b/src/Text/Impl/EditorOperations/Commands/DuplicateSelectionCommandHandler.cs
@@ -0,0 +1,31 @@
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Commanding;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
+using Microsoft.VisualStudio.Utilities;
+
+namespace Microsoft.VisualStudio.Text.Operations.Implementation
+{
+ [Export(typeof(ICommandHandler))]
+ [Name(nameof(DuplicateSelectionCommandHandler))]
+ [ContentType("any")]
+ [TextViewRole(PredefinedTextViewRoles.Editable)]
+ internal sealed class DuplicateSelectionCommandHandler : ICommandHandler<DuplicateSelectionCommandArgs>
+ {
+ [Import]
+ private IEditorOperationsFactoryService OperationsFactory;
+
+ public string DisplayName => Strings.DuplicateSelectionCommandHandlerName;
+
+ public bool ExecuteCommand(DuplicateSelectionCommandArgs args, CommandExecutionContext context)
+ {
+ IEditorOperations3 ops = (IEditorOperations3)OperationsFactory.GetEditorOperations(args.TextView);
+ return ops.DuplicateSelection();
+ }
+
+ public CommandState GetCommandState(DuplicateSelectionCommandArgs args)
+ {
+ return CommandState.Available;
+ }
+ }
+}
diff --git a/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionCommandHandler.cs b/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionCommandHandler.cs
new file mode 100644
index 0000000..c7ec9b1
--- /dev/null
+++ b/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionCommandHandler.cs
@@ -0,0 +1,68 @@
+using System.ComponentModel.Composition;
+using Microsoft.VisualStudio.Commanding;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.Text.Editor.Commanding.Commands;
+using Microsoft.VisualStudio.Utilities;
+
+namespace Microsoft.VisualStudio.Text.Operations.Implementation
+{
+ [Export(typeof(ICommandHandler))]
+ [Name(nameof(ExpandContractSelectionCommandHandler))]
+ [ContentType("any")]
+ [TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
+ [TextViewRole(PredefinedTextViewRoles.EmbeddedPeekTextView)]
+ internal sealed class ExpandContractSelectionCommandHandler
+ : ICommandHandler<ExpandSelectionCommandArgs>, ICommandHandler<ContractSelectionCommandArgs>
+ {
+ [ImportingConstructor]
+ public ExpandContractSelectionCommandHandler(
+ IEditorOptionsFactoryService editorOptionsFactoryService,
+ ITextStructureNavigatorSelectorService navigatorSelectorService)
+ {
+ this.EditorOptionsFactoryService = editorOptionsFactoryService;
+ this.NavigatorSelectorService = navigatorSelectorService;
+ }
+
+ public IEditorOptionsFactoryService EditorOptionsFactoryService { get; }
+
+ private readonly ITextStructureNavigatorSelectorService NavigatorSelectorService;
+
+ public string DisplayName => Strings.ExpandContractSelectionCommandHandlerName;
+
+ public CommandState GetCommandState(ExpandSelectionCommandArgs args)
+ {
+ var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
+ args.TextView,
+ this.EditorOptionsFactoryService,
+ this.NavigatorSelectorService);
+ return storedCommandState.GetExpandCommandState(args.TextView);
+ }
+
+ public CommandState GetCommandState(ContractSelectionCommandArgs args)
+ {
+ var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
+ args.TextView,
+ this.EditorOptionsFactoryService,
+ this.NavigatorSelectorService);
+ return storedCommandState.GetContractCommandState(args.TextView);
+ }
+
+ public bool ExecuteCommand(ExpandSelectionCommandArgs args, CommandExecutionContext context)
+ {
+ var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
+ args.TextView,
+ this.EditorOptionsFactoryService,
+ this.NavigatorSelectorService);
+ return storedCommandState.ExpandSelection(args.TextView);
+ }
+
+ public bool ExecuteCommand(ContractSelectionCommandArgs args, CommandExecutionContext context)
+ {
+ var storedCommandState = ExpandContractSelectionImplementation.GetOrCreateExpandContractState(
+ args.TextView,
+ this.EditorOptionsFactoryService,
+ this.NavigatorSelectorService);
+ return storedCommandState.ContractSelection(args.TextView);
+ }
+ }
+}
diff --git a/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionImplementation.cs b/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionImplementation.cs
new file mode 100644
index 0000000..a26c025
--- /dev/null
+++ b/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionImplementation.cs
@@ -0,0 +1,134 @@
+namespace Microsoft.VisualStudio.Text.Operations.Implementation
+{
+ using System;
+ using System.Collections.Generic;
+ using Microsoft.VisualStudio.Commanding;
+ using Microsoft.VisualStudio.Text.Editor;
+
+ internal class ExpandContractSelectionImplementation
+ {
+ private readonly IEditorOptions editorOptions;
+ private readonly ITextStructureNavigatorSelectorService navigatorSelectorService;
+ private bool ignoreSelectionChangedEvent;
+
+ public static ExpandContractSelectionImplementation GetOrCreateExpandContractState(
+ ITextView textView,
+ IEditorOptionsFactoryService editorOptionsFactoryService,
+ ITextStructureNavigatorSelectorService navigator)
+ {
+ return textView.Properties.GetOrCreateSingletonProperty<ExpandContractSelectionImplementation>(
+ typeof(ExpandContractSelectionImplementation),
+ () => new ExpandContractSelectionImplementation(
+ navigator,
+ editorOptionsFactoryService.GetOptions(textView),
+ textView));
+ }
+
+ private ExpandContractSelectionImplementation(
+ ITextStructureNavigatorSelectorService navigatorSelectorService,
+ IEditorOptions editorOptions,
+ ITextView textView)
+ {
+ this.editorOptions = editorOptions;
+ this.navigatorSelectorService = navigatorSelectorService;
+ textView.Selection.SelectionChanged += this.OnSelectionChanged;
+ }
+
+ // Internal for testing.
+ internal readonly Stack<Tuple<VirtualSnapshotSpan, TextSelectionMode>> previousExpansionsStack
+ = new Stack<Tuple<VirtualSnapshotSpan, TextSelectionMode>>();
+
+ public CommandState GetExpandCommandState(ITextView textView) => CommandState.Available;
+
+ public CommandState GetContractCommandState(ITextView textView)
+ {
+ if (this.previousExpansionsStack.Count > 0)
+ {
+ return CommandState.Available;
+ }
+
+ return CommandState.Unavailable;
+ }
+
+ public bool ExpandSelection(ITextView textView)
+ {
+ try
+ {
+ this.ignoreSelectionChangedEvent = true;
+
+ var navigator = this.GetNavigator(textView);
+ VirtualSnapshotSpan currentSelection = textView.Selection.StreamSelectionSpan;
+ previousExpansionsStack.Push(Tuple.Create(currentSelection, textView.Selection.Mode));
+
+ SnapshotSpan newSelection;
+
+ // If the current language has opt-ed out, return the span of the current word instead.
+ if (this.editorOptions.GetOptionValue(ExpandContractSelectionOptions.ExpandContractSelectionEnabledKey))
+ {
+ // On first invocation, select the current word.
+ if (currentSelection.Length == 0)
+ {
+ newSelection = this.GetNavigator(textView).GetExtentOfWord(currentSelection.Start.Position).Span;
+ }
+ else
+ {
+ newSelection = this.GetNavigator(textView).GetSpanOfEnclosing(currentSelection.SnapshotSpan);
+ }
+ }
+ else
+ {
+ // Since the span of the current word can be left or right associative relative to the caret
+ // in different contexts, to avoid different selections on subsequent invocations of Expand
+ // Selection, always use the center point in the selection to compute the span of the current word.
+ var centerPoint = currentSelection.Start.Position.Add(
+ (currentSelection.End.Position.Position - currentSelection.Start.Position.Position) / 2);
+ newSelection = navigator.GetExtentOfWord(centerPoint).Span;
+ }
+
+ textView.Selection.Mode = TextSelectionMode.Stream;
+ textView.Selection.Select(newSelection, isReversed: false);
+ }
+ finally
+ {
+ this.ignoreSelectionChangedEvent = false;
+ }
+
+ return true; //return true if command is handled
+ }
+
+ public bool ContractSelection(ITextView textView)
+ {
+ try
+ {
+ this.ignoreSelectionChangedEvent = true;
+
+ if (this.previousExpansionsStack.Count > 0)
+ {
+ Tuple<VirtualSnapshotSpan, TextSelectionMode> previousExpansion = this.previousExpansionsStack.Pop();
+ VirtualSnapshotSpan previousExpansionSpan = previousExpansion.Item1;
+ TextSelectionMode previousExpansionSelectionMode = previousExpansion.Item2;
+
+ textView.Selection.Mode = previousExpansionSelectionMode;
+ textView.Selection.Select(previousExpansionSpan.Start, previousExpansionSpan.End);
+ }
+ }
+ finally
+ {
+ this.ignoreSelectionChangedEvent = false;
+ }
+
+ return true;//return true if command is handled
+ }
+
+ private void OnSelectionChanged(object sender, EventArgs eventArgs)
+ {
+ if (!this.ignoreSelectionChangedEvent)
+ {
+ this.previousExpansionsStack.Clear();
+ }
+ }
+
+ private ITextStructureNavigator GetNavigator(ITextView textView)
+ => this.navigatorSelectorService.GetTextStructureNavigator(textView.TextBuffer);
+ }
+}
diff --git a/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionOptionDefinitions.cs b/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionOptionDefinitions.cs
new file mode 100644
index 0000000..b39c3f8
--- /dev/null
+++ b/src/Text/Impl/EditorOperations/Commands/ExpandContractSelectionOptionDefinitions.cs
@@ -0,0 +1,25 @@
+namespace Microsoft.VisualStudio.Text.Operations.Implementation
+{
+ using System.ComponentModel.Composition;
+ using Microsoft.VisualStudio.Text.Editor;
+ using Microsoft.VisualStudio.Text.Operations;
+ using Microsoft.VisualStudio.Utilities;
+
+ /// <summary>
+ /// Defines Expand Contract Selection Option.
+ /// </summary>
+ [Export(typeof(EditorOptionDefinition))]
+ [Name(ExpandContractSelectionOptions.ExpandContractSelectionEnabledOptionId)]
+ internal sealed class ExpandContractSelectionEnabled : EditorOptionDefinition<bool>
+ {
+ /// <summary>
+ /// Gets the default value, which is <c>false</c>.
+ /// </summary>
+ public override bool Default => true;
+
+ /// <summary>
+ /// Gets the default text view host value.
+ /// </summary>
+ public override EditorOptionKey<bool> Key => ExpandContractSelectionOptions.ExpandContractSelectionEnabledKey;
+ }
+}
diff --git a/src/Text/Impl/EditorOperations/Strings.Designer.cs b/src/Text/Impl/EditorOperations/Strings.Designer.cs
index a7ebcea..ffebf8e 100644
--- a/src/Text/Impl/EditorOperations/Strings.Designer.cs
+++ b/src/Text/Impl/EditorOperations/Strings.Designer.cs
@@ -232,6 +232,24 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation {
}
/// <summary>
+ /// Looks up a localized string similar to Duplicate Selection Command Handler.
+ /// </summary>
+ internal static string DuplicateSelectionCommandHandlerName {
+ get {
+ return ResourceManager.GetString("DuplicateSelectionCommandHandlerName", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Expand/Contract Selection Command Handler.
+ /// </summary>
+ internal static string ExpandContractSelectionCommandHandlerName {
+ get {
+ return ResourceManager.GetString("ExpandContractSelectionCommandHandlerName", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Increase line indent.
/// </summary>
internal static string IncreaseLineIndent {
diff --git a/src/Text/Impl/EditorOperations/Strings.resx b/src/Text/Impl/EditorOperations/Strings.resx
index 3246ccd..4792155 100644
--- a/src/Text/Impl/EditorOperations/Strings.resx
+++ b/src/Text/Impl/EditorOperations/Strings.resx
@@ -261,4 +261,10 @@
<data name="DuplicateSelection" xml:space="preserve">
<value>Duplicate Selection</value>
</data>
+ <data name="ExpandContractSelectionCommandHandlerName" xml:space="preserve">
+ <value>Expand/Contract Selection Command Handler</value>
+ </data>
+ <data name="DuplicateSelectionCommandHandlerName" xml:space="preserve">
+ <value>Duplicate Selection Command Handler</value>
+ </data>
</root> \ No newline at end of file