Skip to content

Commit

Permalink
Fix regressions caused by TextWithMarkers change
Browse files Browse the repository at this point in the history
  • Loading branch information
mhutch committed May 23, 2024
1 parent b01e15c commit 238257e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public static Edit WithMarkedSelection (EditKind kind, TextSpan span, string tex
if (spanStart < 0) {
spanStart = cleanTextBuilder.Length;
} else {
spans.Add (new TextSpan (spanStart, cleanTextBuilder.Length));
spans.Add (TextSpan.FromBounds (spanStart, cleanTextBuilder.Length));
spanStart = -1;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using MonoDevelop.Xml.Tests;
using MonoDevelop.Xml.Tests.Utils;

using TextSpan = MonoDevelop.Xml.Dom.TextSpan;

using NUnit.Framework;

namespace MonoDevelop.MSBuild.Tests.Editor
Expand Down Expand Up @@ -50,16 +52,17 @@ public static Task<CodeFixesWithContext> GetRefactorings<T> (this MSBuildEditorT
where T : MSBuildRefactoringProvider, new()
{
var refactoringService = new MSBuildRefactoringService (new[] { new T () });
var textView = test.CreateTextViewWithSelection (documentWithSelection, selectionMarker);
var textView = test.CreateTextViewWithSelection (documentWithSelection, selectionMarker, allowZeroWidthSingleMarker: true);

return test.GetRefactorings (refactoringService, textView, cancellationToken);
}

public static ITextView CreateTextViewWithSelection (this MSBuildEditorTest test, string documentWithSelection, char selectionMarker)
public static ITextView CreateTextViewWithSelection (this MSBuildEditorTest test, string documentWithSelection, char selectionMarker, bool allowZeroWidthSingleMarker = false)
{
var parsed = TextWithMarkers.Parse (documentWithSelection, selectionMarker);

var text = parsed.Text;
var selection = parsed.GetMarkedSpan (selectionMarker);
TextSpan selection = parsed.GetMarkedSpan (selectionMarker, allowZeroWidthSingleMarker);

var textView = test.CreateTextView (text);

Expand Down Expand Up @@ -147,7 +150,7 @@ public static Task<CodeFixesWithContext> GetCodeFixes<TAnalyzer, TCodeFix> (
where TAnalyzer : MSBuildAnalyzer, new()
where TCodeFix : MSBuildFixProvider, new()
{
var textView = test.CreateTextViewWithSelection (documentWithSelection, selectionMarker);
var textView = test.CreateTextViewWithSelection (documentWithSelection, selectionMarker, allowZeroWidthSingleMarker: true);

return test.GetCodeFixes ([new TAnalyzer ()], [new TCodeFix ()], textView, textView.Selection.SelectedSpans.Single(), requestedSeverities, false, null, logger, cancellationToken);
}
Expand Down
2 changes: 1 addition & 1 deletion MonoDevelop.Xml

0 comments on commit 238257e

Please sign in to comment.