Browse files

Decrement the column for 0-indexed source maps

tools.reader uses 1 for the starting index of the line and columns.
Sourcemaps use 0 for the starting index.  So we need to decrement the :column
as well as the :line when making the sourcemap map.

Additionally update the comment about this to be correct.
  • Loading branch information...
1 parent 9773be5 commit cd18069e6acaf6b878b43e2474b1e45dcf105767 @xeqi xeqi committed with swannodette Nov 29, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/clj/cljs/compiler.clj
@@ -140,12 +140,12 @@
:gline (:gen-line m)}
(= (:op ast) :var)
(assoc :name (str (-> ast :info :name))))]
- ; Dec the line number for 0-indexed line numbers.
- ; tools.reader has 0-indexed line number, chrome
- ; expects 1-indexed source maps.
+ ; Dec the line/column numbers for 0-indexing.
+ ; tools.reader uses 1-indexed sources, chrome
+ ; expects 0-indexed source maps.
(update-in m [:source-map (dec line)]
(fnil (fn [line]
- (update-in line [(or column 0)]
+ (update-in line [(if column (dec column) 0)]
(fnil (fn [column] (conj column minfo)) [])))
(emit* ast)))

0 comments on commit cd18069

Please sign in to comment.