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
diff options
context:
space:
mode:
authorAaron Bockover <abock@microsoft.com>2019-09-13 00:32:34 +0300
committerAaron Bockover <abock@microsoft.com>2019-09-13 00:32:34 +0300
commit76a8f91dc4a1a620eb8ccc730753d0e4ff784eb3 (patch)
tree7ec1c3b962f9d2491e0cb9d9c2b6cfc4362ca36c
parentdafa09a0b9918256badd17d9ef6ebe2e08ff9d5e (diff)
Sync with vs-editor-core@28bf8d91
-rw-r--r--src/Editor/Text/Def/TextUI/Commanding/CommandSelector.cs12
-rw-r--r--src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToNextErrorInDocumentCommandArgs.cs21
-rw-r--r--src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToPreviousErrorInDocumentCommandArgs.cs21
-rw-r--r--src/Editor/Text/Impl/EditorOperations/Commands/NavigateToNextIssueCommandHandler.cs92
4 files changed, 115 insertions, 31 deletions
diff --git a/src/Editor/Text/Def/TextUI/Commanding/CommandSelector.cs b/src/Editor/Text/Def/TextUI/Commanding/CommandSelector.cs
index 91e2050..17e771c 100644
--- a/src/Editor/Text/Def/TextUI/Commanding/CommandSelector.cs
+++ b/src/Editor/Text/Def/TextUI/Commanding/CommandSelector.cs
@@ -291,6 +291,18 @@ namespace Microsoft.VisualStudio.Text.Editor.Commanding
/// <summary>⇧⌥⇣</summary>
public const string ContractSelection = "contractSelection:";
+ /// <summary>⌥⇡</summary>
+ public const string NavigateToPreviousIssueInDocument = "navigateToPreviousIssueInDocument:";
+
+ /// <summary>⌥⇣</summary>
+ public const string NavigateToNextIssueInDocument = "navigateToNextIssueInDocument:";
+
+ /// <summary>⌘⌥⇡</summary>
+ public const string NavigateToPreviousErrorInDocument = "navigateToPreviousErrorInDocument:";
+
+ /// <summary>⌘⌥⇣</summary>
+ public const string NavigateToNextErrorInDocument = "navigateToNextErrorInDocument:";
+
#endregion
}
diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToNextErrorInDocumentCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToNextErrorInDocumentCommandArgs.cs
new file mode 100644
index 0000000..2039755
--- /dev/null
+++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToNextErrorInDocumentCommandArgs.cs
@@ -0,0 +1,21 @@
+namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands
+{
+ using Microsoft.VisualStudio.Text.Adornments;
+
+ /// <summary>
+ /// <see cref="EditorCommandArgs"/> for next error command.
+ /// </summary>
+ public sealed class NavigateToNextErrorInDocumentCommandArgs : ErrorCommandArgsBase
+ {
+ /// <summary>
+ /// Creates an instance of <see cref="NavigateToNextErrorInDocumentCommandArgs"/> with a list
+ /// that contains only errors (exlucdes hinted suggestions and warnings).
+ /// </summary>
+ /// <param name="textView">The <see cref="ITextView"/> upon which to invoke the command.</param>
+ /// <param name="subjectBuffer">The <see cref="ITextBuffer"/> upon which to invoke the command.</param>
+ public NavigateToNextErrorInDocumentCommandArgs(ITextView textView, ITextBuffer subjectBuffer)
+ : base(textView, subjectBuffer, new [] { PredefinedErrorTypeNames.CompilerError, PredefinedErrorTypeNames.OtherError, PredefinedErrorTypeNames.SyntaxError })
+ {
+ }
+ }
+}
diff --git a/src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToPreviousErrorInDocumentCommandArgs.cs b/src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToPreviousErrorInDocumentCommandArgs.cs
new file mode 100644
index 0000000..fb65d83
--- /dev/null
+++ b/src/Editor/Text/Def/TextUI/Commanding/Commands/NavigateToPreviousErrorInDocumentCommandArgs.cs
@@ -0,0 +1,21 @@
+namespace Microsoft.VisualStudio.Text.Editor.Commanding.Commands
+{
+ using Microsoft.VisualStudio.Text.Adornments;
+
+ /// <summary>
+ /// <see cref="EditorCommandArgs"/> for next error command.
+ /// </summary>
+ public sealed class NavigateToPreviousErrorInDocumentCommandArgs : ErrorCommandArgsBase
+ {
+ /// <summary>
+ /// Creates an instance of <see cref="NavigateToPreviousErrorInDocumentCommandArgs"/> with a list
+ /// that contains only errors (exlucdes hinted suggestions and warnings).
+ /// </summary>
+ /// <param name="textView">The <see cref="ITextView"/> upon which to invoke the command.</param>
+ /// <param name="subjectBuffer">The <see cref="ITextBuffer"/> upon which to invoke the command.</param>
+ public NavigateToPreviousErrorInDocumentCommandArgs(ITextView textView, ITextBuffer subjectBuffer)
+ : base(textView, subjectBuffer, new [] { PredefinedErrorTypeNames.CompilerError, PredefinedErrorTypeNames.OtherError, PredefinedErrorTypeNames.SyntaxError })
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/src/Editor/Text/Impl/EditorOperations/Commands/NavigateToNextIssueCommandHandler.cs b/src/Editor/Text/Impl/EditorOperations/Commands/NavigateToNextIssueCommandHandler.cs
index 25948cf..3b51151 100644
--- a/src/Editor/Text/Impl/EditorOperations/Commands/NavigateToNextIssueCommandHandler.cs
+++ b/src/Editor/Text/Impl/EditorOperations/Commands/NavigateToNextIssueCommandHandler.cs
@@ -15,18 +15,18 @@
[Name("default " + nameof(NavigateToNextIssueCommandHandler))]
[ContentType("any")]
[TextViewRole(PredefinedTextViewRoles.Analyzable)]
- internal sealed class NavigateToNextIssueCommandHandler : ICommandHandler<NavigateToNextIssueInDocumentCommandArgs>, ICommandHandler<NavigateToPreviousIssueInDocumentCommandArgs>
+ internal sealed class NavigateToNextIssueCommandHandler :
+ ICommandHandler<NavigateToNextIssueInDocumentCommandArgs>,
+ ICommandHandler<NavigateToPreviousIssueInDocumentCommandArgs>,
+ ICommandHandler<NavigateToNextErrorInDocumentCommandArgs>,
+ ICommandHandler<NavigateToPreviousErrorInDocumentCommandArgs>
{
[Import]
private Lazy<IBufferTagAggregatorFactoryService> tagAggregatorFactoryService;
public string DisplayName => Strings.NextIssue;
- #region Previous Issue
-
- public CommandState GetCommandState(NavigateToPreviousIssueInDocumentCommandArgs args) => CommandState.Available;
-
- public bool ExecuteCommand(NavigateToPreviousIssueInDocumentCommandArgs args, CommandExecutionContext executionContext)
+ private bool NavigateToNextIssue(ErrorCommandArgsBase args, CommandExecutionContext executionContext)
{
var snapshot = args.TextView.TextSnapshot;
var spans = this.GetTagSpansCollection(snapshot, args.ErrorTagTypeNames);
@@ -38,17 +38,24 @@
(int indexOfErrorSpan, bool containsPoint) = IndexOfTagSpanNearPoint(spans, args.TextView.Caret.Position.BufferPosition.Position);
- int nextIndex = indexOfErrorSpan - 1;
- if (containsPoint && (spans.Count == 1))
+ int nextIndex = indexOfErrorSpan + 1;
+ if (containsPoint)
{
- // There is only one error tag and it contains the caret. Ensure it stays put.
- return true;
+ if (spans.Count == 1)
+ {
+ // There is only one error tag and it contains the caret. Ensure it stays put.
+ return true;
+ }
+ }
+ else
+ {
+ nextIndex = indexOfErrorSpan;
}
// Wrap if needed.
- if (nextIndex < 0)
+ if ((indexOfErrorSpan == -1) || (nextIndex >= spans.Count))
{
- nextIndex = (spans.Count - 1);
+ nextIndex = 0;
}
args.TextView.Caret.MoveTo(new SnapshotPoint(snapshot, spans[nextIndex].Start));
@@ -56,12 +63,7 @@
return true;
}
- #endregion
-
- #region Next Issue
- public CommandState GetCommandState(NavigateToNextIssueInDocumentCommandArgs args) => CommandState.Available;
-
- public bool ExecuteCommand(NavigateToNextIssueInDocumentCommandArgs args, CommandExecutionContext executionContext)
+ private bool NavigateToPreviousIssue(ErrorCommandArgsBase args, CommandExecutionContext executionContext)
{
var snapshot = args.TextView.TextSnapshot;
var spans = this.GetTagSpansCollection(snapshot, args.ErrorTagTypeNames);
@@ -73,24 +75,17 @@
(int indexOfErrorSpan, bool containsPoint) = IndexOfTagSpanNearPoint(spans, args.TextView.Caret.Position.BufferPosition.Position);
- int nextIndex = indexOfErrorSpan + 1;
- if (containsPoint)
- {
- if (spans.Count == 1)
- {
- // There is only one error tag and it contains the caret. Ensure it stays put.
- return true;
- }
- }
- else
+ int nextIndex = indexOfErrorSpan - 1;
+ if (containsPoint && (spans.Count == 1))
{
- nextIndex = indexOfErrorSpan;
+ // There is only one error tag and it contains the caret. Ensure it stays put.
+ return true;
}
// Wrap if needed.
- if ((indexOfErrorSpan == -1) || (nextIndex >= spans.Count))
+ if (nextIndex < 0)
{
- nextIndex = 0;
+ nextIndex = (spans.Count - 1);
}
args.TextView.Caret.MoveTo(new SnapshotPoint(snapshot, spans[nextIndex].Start));
@@ -98,6 +93,41 @@
return true;
}
+ #region Previous Issue
+ public CommandState GetCommandState(NavigateToPreviousIssueInDocumentCommandArgs args) => CommandState.Available;
+
+ public bool ExecuteCommand(NavigateToPreviousIssueInDocumentCommandArgs args, CommandExecutionContext executionContext)
+ {
+ return NavigateToPreviousIssue(args, executionContext);
+ }
+ #endregion
+
+ #region Next Issue
+ public CommandState GetCommandState(NavigateToNextIssueInDocumentCommandArgs args) => CommandState.Available;
+
+ public bool ExecuteCommand(NavigateToNextIssueInDocumentCommandArgs args, CommandExecutionContext executionContext)
+ {
+ return NavigateToNextIssue(args, executionContext);
+ }
+ #endregion
+
+
+ #region Next Error
+ public CommandState GetCommandState(NavigateToNextErrorInDocumentCommandArgs args) => CommandState.Available;
+
+ public bool ExecuteCommand(NavigateToNextErrorInDocumentCommandArgs args, CommandExecutionContext executionContext)
+ {
+ return NavigateToNextIssue(args, executionContext);
+ }
+ #endregion
+
+ #region Prev Error
+ public CommandState GetCommandState(NavigateToPreviousErrorInDocumentCommandArgs args) => CommandState.Available;
+
+ public bool ExecuteCommand(NavigateToPreviousErrorInDocumentCommandArgs args, CommandExecutionContext executionContext)
+ {
+ return NavigateToPreviousIssue(args, executionContext);
+ }
#endregion
private static (int index, bool containsPoint) IndexOfTagSpanNearPoint(NormalizedSpanCollection spans, int point)