Skip to content

Commit

Permalink
Add column information to generated source maps
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 23, 2013
1 parent 95c97e3 commit c7ba09b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/opal/fragment.rb
Expand Up @@ -33,5 +33,9 @@ def inspect
def line
@sexp.line if @sexp
end

def column
@sexp.column if @sexp
end
end
end
10 changes: 7 additions & 3 deletions lib/opal/source_map.rb
Expand Up @@ -21,15 +21,19 @@ def map
:generated_line => line,
:generated_col => column,
:source_line => source_line,
:source_col => 0,
:source_col => fragment.column,
:source => file
)
end


new_lines = fragment.code.count "\n"
line += new_lines
column = 0

if new_lines > 0
column = fragment.code.size - (fragment.code.rindex("\n") + 1)
else
column += fragment.code.size
end
end
end
end
Expand Down

0 comments on commit c7ba09b

Please sign in to comment.