mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
API: buf_get_lines, buf_line_count handle unloaded buffers #7688
This commit is contained in:
@@ -45,6 +45,11 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// return sentinel value if the buffer isn't loaded
|
||||
if (buf->b_ml.ml_mfp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return buf->b_ml.ml_line_count;
|
||||
}
|
||||
|
||||
@@ -221,6 +226,11 @@ ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// return sentinel value if the buffer isn't loaded
|
||||
if (buf->b_ml.ml_mfp == NULL) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool oob = false;
|
||||
start = normalize_index(buf, start, &oob);
|
||||
end = normalize_index(buf, end, &oob);
|
||||
|
Reference in New Issue
Block a user