Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #854 from tkellogg/dollar-newline

Made `$` match end of line
  • Loading branch information...
commit 72651febd20779c720bd35747315aaeb78affa7a 2 parents 09647c2 + 8842f3a
@jaredpar authored
Showing with 19 additions and 1 deletion.
  1. +11 −1 VimCore/VimRegex.fs
  2. +8 −0 VimCoreTest/VimRegexTest.cs
View
12 VimCore/VimRegex.fs
@@ -231,6 +231,13 @@ module VimRegexFactory =
RegexOptions.None
else
RegexOptions.Compiled
+
+ let regexOptions =
+ if data.IncludesNewLine then
+ regexOptions
+ else
+ regexOptions ||| RegexOptions.Multiline
+
if data.MatchCase then
regexOptions
else
@@ -260,7 +267,10 @@ module VimRegexFactory =
| '}' -> if data.IsRangeOpen then data.EndRange() else data.AppendChar '}'
| '|' -> data.AppendChar '|'
| '^' -> if data.IsStartOfPattern || data.IsStartOfGrouping then data.AppendChar '^' else data.AppendEscapedChar '^'
- | '$' -> if data.IsEndOfPattern then data.AppendChar '$' else data.AppendEscapedChar '$'
+ | '$' ->
+ if data.IsEndOfPattern then
+ data.AppendString @"\r?$"
+ else data.AppendEscapedChar '$'
| '<' -> data.AppendString @"\b"
| '>' -> data.AppendString @"\b"
| '[' -> data.BeginGrouping()
View
8 VimCoreTest/VimRegexTest.cs
@@ -1108,5 +1108,13 @@ public void NewLine_Replace()
VerifyReplace(@"\n", "hello\r\nworld", " ", "hello world");
VerifyReplace(@"\n", "hello\rworld", " ", "hello world");
}
+
+ [Test]
+ public void Newline_DollarSignMatchesEndOfLine()
+ {
+ VerifyMatches(@"foo$", "foo\r\nbar");
+ VerifyMatches(@"foo$", "foo\nbar");
+ VerifyMatches(@"foo$", "foo");
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.