Append anchor characters when placeholder is not added

This commit is contained in:
Kevin Sawicki 2012-12-20 21:08:09 -08:00
parent 4c1ecf61df
commit 8aba95191d
2 changed files with 18 additions and 2 deletions

View File

@ -337,6 +337,14 @@ describe "TokenizedBuffer", ->
afterEach ->
editSession.destroy()
it "correctly parses a long line", ->
longLine = tokenizedBuffer.lineForScreenRow(0)
expect(longLine.text).toBe "longggggggggggggggggggggggggggggggggggggggggggggggg"
{ tokens } = longLine
expect(tokens[0].value).toBe "longggggggggggggggggggggggggggggggggggggggggggggggg"
expect(tokens[0].scopes).toEqual ["text.git-commit", "meta.scope.message.git-commit", "invalid.deprecated.line-too-long.git-commit"]
it "correctly parses the number sign of the first comment line", ->
commentLine = tokenizedBuffer.lineForScreenRow(1)
expect(commentLine.text).toBe "# Please enter the commit message for your changes. Lines starting"

View File

@ -176,8 +176,16 @@ class Pattern
for character in @regexSource.split('')
if escape
switch character
when 'A' then escaped.push(placeholder) unless firstLine
when 'G' then escaped.push(placeholder) unless offset is anchor
when 'A'
if firstLine
escaped.push("\\#{character}")
else
escaped.push(placeholder)
when 'G'
if offset is anchor
escaped.push("\\#{character}")
else
escaped.push(placeholder)
when 'z' then escaped.push('$(?!\n)(?<!\n)')
else escaped.push("\\#{character}")
escape = false