Skip to content

Commit

Permalink
Text-object delete/change fix edgecase
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamm committed Feb 21, 2016
1 parent 9f4b9d8 commit 5a103ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Src/VimCore/MotionUtil.fs
Expand Up @@ -1074,7 +1074,13 @@ type internal MotionUtil
| None -> false
| Some point -> SnapshotPointUtil.GetChar point = '\\'

let isChar c point = SnapshotPointUtil.GetChar point = c && not (isEscaped point)
let isDoubleEscaped point =
match SnapshotPointUtil.TrySubtract point 2, SnapshotPointUtil.TrySubtract point 2 with
| None, _
| _, None -> false
| Some point1, Some point2 -> SnapshotPointUtil.GetChar point1 = '\\' && SnapshotPointUtil.GetChar point2 = '\\'

let isChar c point = SnapshotPointUtil.GetChar point = c && (not (isEscaped point) || isDoubleEscaped point)

let findMatched plusChar minusChar =
let inner point count =
Expand Down
9 changes: 8 additions & 1 deletion Test/VimCoreTest/MotionUtilTest.cs
Expand Up @@ -593,7 +593,6 @@ public void CountWithSideBySideBlocksHarder()
Assert.Equal("cat (dog)(blah)(again(deep))", motionResult.Span.GetText());
}


/// <summary>
/// Single line inner block test should use inner block behavior
/// </summary>
Expand Down Expand Up @@ -648,6 +647,14 @@ public void ContentOnLineWithClosingBracket()
var lines = _motionUtil.InnerBlock(_textBuffer.GetPointInLine(1, 1), BlockKind.Bracket, 1).Value.Span.GetText();
Assert.Equal(" " + Environment.NewLine + " cat" + Environment.NewLine + " dog ", lines);
}

[Fact]
public void DisregardDoubleCommentedMatchType()
{
Create(@"OutlineFileNameRegex(DuplicateBackslash(L""^OutlineFileName:(.*\\.*\\\\).* $""));");
var motion = _motionUtil.InnerBlock(_textBuffer.GetPoint(22), BlockKind.Paren, 1);
Assert.Equal(@"DuplicateBackslash(L""^OutlineFileName:(.*\\.*\\\\).* $"")", motion.Value.Span.GetText());
}
}

public sealed class QuotedStringTest : MotionUtilTest
Expand Down

0 comments on commit 5a103ce

Please sign in to comment.