Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/coffee-script/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ exports.Lexer = class Lexer
@token 'CALL_START', '(', 0, 0
@mergeInterpolationTokens tokens, {delimiter: '"', double: yes}, @formatHeregex
if flags
@token ',', ',', index, 0
@token 'STRING', '"' + flags + '"', index, flags.length
@token ')', ')', end, 0
@token 'REGEX_END', ')', end, 0
@token ',', ',', index - 1, 0
@token 'STRING', '"' + flags + '"', index - 1, flags.length
@token ')', ')', end - 1, 0
@token 'REGEX_END', ')', end - 1, 0

end

Expand Down
23 changes: 23 additions & 0 deletions test/location.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,29 @@ test "Verify indented heredocs have the right position", ->
eq stringToken[2].last_line, 3
eq stringToken[2].last_column, 4

test "Verify heregexes with interpolations have the right ending position", ->
source = '''
[a ///#{b}///g]
'''
[..., stringEnd, comma, flagsString, regexCallEnd, regexEnd, fnCallEnd,
arrayEnd, terminator] = CoffeeScript.tokens source

eq comma[0], ','
eq arrayEnd[0], ']'

assertColumn = (token, column) ->
eq token[2].first_line, 0
eq token[2].first_column, column
eq token[2].last_line, 0
eq token[2].last_column, column

arrayEndColumn = arrayEnd[2].first_column
for token in [comma, flagsString]
assertColumn token, arrayEndColumn - 2
for token in [regexCallEnd, regexEnd, fnCallEnd]
assertColumn token, arrayEndColumn - 1
assertColumn arrayEnd, arrayEndColumn

test "Verify all tokens get a location", ->
doesNotThrow ->
tokens = CoffeeScript.tokens testScript
Expand Down