diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index e0c17d223..304f2a3f8 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -1387,7 +1387,7 @@ int parse_execution_context_t::line_offset_of_character_at_offset(size_t offset) const wchar_t *str = pstree->src.c_str(); if (offset > cached_lineno_offset) { size_t i; - for (i = cached_lineno_offset; str[i] != L'\0' && i < offset; i++) { + for (i = cached_lineno_offset; i < offset && str[i] != L'\0'; i++) { // Add one for every newline we find in the range [cached_lineno_offset, offset). if (str[i] == L'\n') { cached_lineno_count++;