Regex searches are case-sensitive if any letter is capitalized.

Fixes bug introduced in commit aa3f674948
This commit is contained in:
Corey Johnson 2012-09-25 18:35:44 -07:00
parent dd81e69bfb
commit 8328875021
2 changed files with 14 additions and 8 deletions

View File

@ -163,19 +163,25 @@ describe "CommandInterpreter", ->
it "is case-insentive when the pattern contains no non-escaped uppercase letters (behavior copied from vim)", ->
waitsForPromise ->
editSession.setSelectedBufferRange([[4,16], [4,20]])
interpreter.eval('/array', editSession)
runs ->
expect(editSession.getSelection().getBufferRange()).toEqual [[11,14], [11,19]]
expect(interpreter.lastRelativeAddress.subcommands[0].regex.toString()).toEqual "/array/i"
waitsForPromise ->
editSession.setSelectedBufferRange([[4,16], [4,20]])
interpreter.eval('/a\\Sray', editSession) # You must escape the backslash, otherwise it is treated as an escaped 'S'
interpreter.eval('/a\\Sray', editSession)
runs ->
expect(editSession.getSelection().getBufferRange()).toEqual [[11,14], [11,19]]
expect(interpreter.lastRelativeAddress.subcommands[0].regex.toString()).toEqual "/a\\Sray/i"
it "is case-sentive when the pattern contains a non-escaped uppercase letters (behavior copied from vim)", ->
waitsForPromise ->
interpreter.eval('/arRay', editSession)
runs ->
expect(interpreter.lastRelativeAddress.subcommands[0].regex.toString()).toEqual "/arRay/"
waitsForPromise ->
interpreter.eval('/Array', editSession)
runs ->
expect(interpreter.lastRelativeAddress.subcommands[0].regex.toString()).toEqual "/Array/"
describe "address range", ->
describe "when two addresses are specified", ->

View File

@ -10,7 +10,7 @@ class RegexAddress extends Address
flags = ""
pattern = pattern.source if pattern.source
patternContainsCapitalLetter = /[^\\][A-Z]/.test(pattern)
patternContainsCapitalLetter = /(^|[^\\])[A-Z]/.test(pattern)
flags += "i" unless patternContainsCapitalLetter
@isReversed = isReversed