Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update bleeding line number to be less specific.

Not as important as the last one, but whitespace isn't the only multiline token, just making it less generic.
  • Loading branch information...
commit 96f7e19fecb5ccb0b9f83fdeacc1cd23b5400675 1 parent 0bb714a
@blainesch blainesch authored
Showing with 12 additions and 3 deletions.
  1. +1 −3 analysis/Parser.php
  2. +11 −0 tests/cases/analysis/ParserTest.php
View
4 analysis/Parser.php
@@ -75,9 +75,7 @@ public static function tokenize($code, array $options = array()) {
}
$tokens[] = array('id' => $id, 'name' => $name, 'content' => $content, 'line' => $line);
- if ($id === T_WHITESPACE) {
- $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
- }
+ $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
}
if ($options['wrap'] && empty($options['include'])) {
View
11 tests/cases/analysis/ParserTest.php
@@ -153,6 +153,17 @@ public function testParserGuessesLineBleed() {
$this->assertIdentical(3, $tokens[13]['line']);
}
+ public function testParserGuessesLineBleedWithNonWhitespace() {
+ $code = <<<EOD
+if (false) {
+ // hello world
+}
+EOD;
+ $tokens = Parser::tokenize($code);
+ $this->assertIdentical('}', $tokens[9]['content']);
+ $this->assertIdentical(3, $tokens[9]['line']);
+ }
+
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.