Avoided trailing \r in CharStream::lineAtPosition().

This commit is contained in:
a3d4 2020-02-10 01:16:55 +01:00
parent e8eb1f2d14
commit be1d92c836

View File

@ -93,10 +93,13 @@ string CharStream::lineAtPosition(int _position) const
lineStart = 0;
else
lineStart++;
return m_source.substr(
string line = m_source.substr(
lineStart,
min(m_source.find('\n', lineStart), m_source.size()) - lineStart
);
if (!line.empty() && line.back() == '\r')
line.pop_back();
return line;
}
tuple<int, int> CharStream::translatePositionToLineColumn(int _position) const