Fix prefix/suffix/equal matcher to trim whitespaces

- Prefix matcher will trim leading whitespaces only when the pattern
  doesn't start with a whitespace
- Suffix matcher will trim trailing whitespaces only when the pattern
  doesn't end with a whitespace
- Equal matcher will trim leading whitespaces only when the pattern
  doesn't start with a whitespace, and trim trailing whitespaces only
  when the pattern doesn't end with a whitespace

Previously, only suffix matcher would trim whitespaces unconditionally.

Fix #1894
This commit is contained in:
Junegunn Choi
2020-03-01 12:36:02 +09:00
parent b2c0413a98
commit 4c9cab3f8a
4 changed files with 60 additions and 9 deletions

View File

@@ -98,6 +98,9 @@ func TestEqual(t *testing.T) {
}
match("ABC", -1, -1)
match("AbC", 0, 3)
match("AbC ", 0, 3)
match(" AbC ", 1, 4)
match(" AbC", 2, 5)
}
func TestCaseSensitivity(t *testing.T) {