Respond to comment

This commit is contained in:
Peter Elmers 2017-11-22 09:52:33 -08:00 committed by Jacob Dufault
parent 3341b1f13d
commit 750cc4ea30
3 changed files with 4 additions and 3 deletions

View File

@ -273,6 +273,7 @@ bool lsPosition::operator==(const lsPosition& other) const {
std::string lsPosition::ToString() const {
return std::to_string(line) + ":" + std::to_string(character);
}
const lsPosition lsPosition::kZeroPosition = lsPosition();
lsRange::lsRange() {}
lsRange::lsRange(lsPosition start, lsPosition end) : start(start), end(end) {}

View File

@ -148,6 +148,7 @@ struct lsPosition {
// Note: these are 0-based.
int line = 0;
int character = 0;
static const lsPosition kZeroPosition;
};
MAKE_HASHABLE(lsPosition, t.line, t.character);
MAKE_REFLECT_STRUCT(lsPosition, line, character);

View File

@ -329,9 +329,8 @@ void WorkingFiles::OnChange(const Ipc_TextDocumentDidChange::Params& change) {
// std::cerr << "|" << file->buffer_content << "|" << std::endl;
// Per the spec replace everything if the rangeLength and range are not set.
// See https://github.com/Microsoft/language-server-protocol/issues/9.
auto zeroPosition = lsPosition(0, 0);
if (diff.rangeLength == -1 && diff.range.start == zeroPosition
&& diff.range.end == zeroPosition) {
if (diff.rangeLength == -1 && diff.range.start == lsPosition::kZeroPosition
&& diff.range.end == lsPosition::kZeroPosition) {
file->buffer_content = diff.text;
file->OnBufferContentUpdated();
// std::cerr << "-> Replacing entire content";