diff --git a/src/working_files.cc b/src/working_files.cc index 93354640..5c01b4b3 100644 --- a/src/working_files.cc +++ b/src/working_files.cc @@ -74,9 +74,11 @@ optional WorkingFile::GetBufferLineFromIndexLine(int index_line) const { // Note: |index_line| and |buffer_line| are 1-based. // TODO: reenable this assert once we are using the real indexed file. - assert(index_line >= 1 && index_line <= index_lines.size()); - //if (index_line < 1 || index_line > index_lines.size()) - // return nullopt; + //assert(index_line >= 1 && index_line <= index_lines.size()); + if (index_line < 1 || index_line > index_lines.size()) { + std::cerr << "!! Bad index_line (got " << index_line << ", expected [1, " << index_lines.size() << "])" << std::endl; + return nullopt; + } // Find the line in the cached index file. We'll try to find the most similar line // in the buffer and return the index for that. @@ -108,9 +110,11 @@ optional WorkingFile::GetIndexLineFromBufferLine(int buffer_line) const { // See GetBufferLineFromIndexLine for additional comments. // Note: |index_line| and |buffer_line| are 1-based. - assert(buffer_line >= 1 && buffer_line < all_buffer_lines.size()); - //if (buffer_line < 1 || buffer_line > all_buffer_lines.size()) - // return nullopt; + //assert(buffer_line >= 1 && buffer_line < all_buffer_lines.size()); + if (buffer_line < 1 || buffer_line > all_buffer_lines.size()) { + std::cerr << "!! Bad buffer_line (got " << buffer_line << ", expected [1, " << all_buffer_lines.size() << "])" << std::endl; + return nullopt; + } // Find the line in the index file. We'll try to find the most similar line // in the index file and return the index for that.