Skip to content

Commit

Permalink
working_files: normalize \r\n and \n to \n
Browse files Browse the repository at this point in the history
Some clients may normalize end-of-line sequences, thus cause a mismatch
between index_lines and buffer_lines.
  • Loading branch information
MaskRay committed Mar 1, 2019
1 parent 00158e2 commit 86fe121
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/working_files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ std::vector<std::string> ToLines(const std::string &content) {
std::vector<std::string> result;
std::istringstream lines(content);
std::string line;
while (getline(lines, line))
while (getline(lines, line)) {
if (line.size() && line.back() == '\r')
line.pop_back();
result.push_back(line);
}
return result;
}

Expand Down

0 comments on commit 86fe121

Please sign in to comment.