mirror of
https://github.com/neovim/neovim.git
synced 2026-07-22 09:01:45 +00:00
feat(extmark): support end_col=-1 if strict=false #28169
Problem: There is an inconsistency between extmarks/highlights regarding the `end_col` param. Solution: Allow end_col=-1 to mean "end of line" (if strict=false). Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -402,7 +402,7 @@ ArrayOf(DictAs(get_extmark_item)) nvim_buf_get_extmarks(Buffer buffer, Integer n
|
||||
/// @param opts Optional parameters.
|
||||
/// - id : id of the extmark to edit.
|
||||
/// - end_row : ending line of the mark, 0-based inclusive.
|
||||
/// - end_col : ending col of the mark, 0-based exclusive.
|
||||
/// - end_col : ending col of the mark, 0-based exclusive, or -1 to extend the range to end of line.
|
||||
/// - hl_group : highlight group used for the text range. This and below
|
||||
/// highlight groups can be supplied either as a string or as an integer,
|
||||
/// the latter of which can be obtained using |nvim_get_hl_id_by_name()|.
|
||||
@@ -586,9 +586,13 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
|
||||
colnr_T col2 = -1;
|
||||
if (HAS_KEY(opts, set_extmark, end_col)) {
|
||||
Integer val = opts->end_col;
|
||||
VALIDATE_RANGE((val >= 0 && val <= MAXCOL), "end_col", {
|
||||
VALIDATE_RANGE((val >= -1 && val <= MAXCOL), "end_col", {
|
||||
goto error;
|
||||
});
|
||||
if (val == -1) {
|
||||
val = MAXCOL;
|
||||
}
|
||||
|
||||
col2 = (int)val;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user