Skip to content

Commit

Permalink
Fix indented syntax line numbering with DOS lines.
Browse files Browse the repository at this point in the history
Closes #588
  • Loading branch information
nex3 committed Jan 5, 2013
1 parent d2d40ed commit ba7bd68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc-src/SASS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* Ruby 2.0.0-preview compatibility. Thanks to [Eric
Saxby](http://www.livinginthepast.org/).

* Fix incorrect line numbering when using DOS line endings with the indented
syntax.

## 3.2.4

* Fix imports from `.jar` files in JRuby. Thanks to [Alex
Expand Down
2 changes: 1 addition & 1 deletion lib/sass/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def tabulate(string)
comment_tab_str = nil
first = true
lines = []
string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^[^\n]*?$/).each_with_index do |line, index|
string.gsub(/\r\n|\r|\n/, "\n").scan(/^[^\n]*?$/).each_with_index do |line, index|
index += (@options[:line] || 1)
if line.strip.empty?
lines.last.text << "\n" if lines.last && lines.last.comment?
Expand Down
15 changes: 15 additions & 0 deletions test/sass/engine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,21 @@ def test_variables_in_media

# Regression tests

def test_line_numbers_with_dos_line_endings
assert_equal <<CSS, render(<<SASS, :line_comments => true)
/* line 5, test_line_numbers_with_dos_line_endings_inline.sass */
.foo {
a: b; }
CSS
\r
\r
\r
\r
.foo
a: b
SASS
end

def test_variable_in_media_in_mixin
assert_equal <<CSS, render(<<SASS)
@media screen and (min-width: 10px) {
Expand Down

0 comments on commit ba7bd68

Please sign in to comment.