Permalink
Browse files

Fix some off-by-one bugs in column calculations.

  • Loading branch information...
1 parent 8c892df commit 88be380bca3f1c330421e629421b9b215bacf03e Alexander Pavlov committed with nex3 Sep 18, 2012
Showing with 3 additions and 3 deletions.
  1. +1 −1 lib/sass/scss/parser.rb
  2. +2 −2 lib/sass/tree/visitors/to_css.rb
View
@@ -1178,7 +1178,7 @@ def tok(rx, last_group_lookahead = false)
newline_count = res.count(NEWLINE)
if newline_count > 0
@line += newline_count
- @offset = Sass::Util::char_size(res[res.rindex(NEWLINE)+1..-1])
+ @offset = Sass::Util::char_size(res[res.rindex(NEWLINE)..-1])
else
@offset += Sass::Util::char_size(res)
end
@@ -60,7 +60,7 @@ def erase!(chars)
newlines = str.count("\n")
if newlines > 0
@line -= newlines
- @column = (@result.rindex("\n") || @result.length) + 1
+ @column = Sass::Util::char_size(@result[@result.rindex("\n") || 0..-1])
else
@column -= chars
end
@@ -77,7 +77,7 @@ def output(s)
newlines = s.count("\n")
if newlines > 0
@line += newlines
- @column = s.rindex("\n") + 1
+ @column = Sass::Util::char_size(s[s.rindex("\n")..-1])
else
@column += Sass::Util::char_size(s)
end

0 comments on commit 88be380

Please sign in to comment.