Index: extensions/browser/file_highlighter.cc |
diff --git a/extensions/browser/file_highlighter.cc b/extensions/browser/file_highlighter.cc |
index d3edeca42cf7bb0eed41ef2f95df899de1700816..d8acdb494bfe09c221c290d2531178865088ccc0 100644 |
--- a/extensions/browser/file_highlighter.cc |
+++ b/extensions/browser/file_highlighter.cc |
@@ -203,8 +203,21 @@ SourceHighlighter::~SourceHighlighter() { |
} |
void SourceHighlighter::Parse(size_t line_number) { |
- for (size_t i = 1; i < line_number; ++i) |
- start_ = contents_.find('\n', start_) + 1; |
+ // If line 0 is requested, highlight nothing. |
+ if (line_number == 0) { |
+ start_ = contents_.size(); |
+ return; |
+ } |
+ |
+ for (size_t i = 1; i < line_number; ++i) { |
+ start_ = contents_.find('\n', start_); |
+ // If we find the end of the string, then break. Otherwise, increment start |
+ // to be at the first character of the new line. |
Finnur
2013/09/09 18:19:30
One doesn't gain much information from this commen
Devlin
2013/09/09 18:26:16
Removed.
|
+ if (start_ == std::string::npos) |
+ break; |
+ start_ += 1; |
+ } |
+ |
end_ = contents_.find('\n', start_); |
// If we went off the end of the string (i.e., the line number was invalid), |