diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-11-08 12:17:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-08 12:17:25 +0100 |
commit | 1b0fd377aba3b4d076e4dbfb5adb96866a4982d1 (patch) | |
tree | 460bbeada52d9b7bd3a1ad194224cec461f7f055 /src/nvim/api/extmark.c | |
parent | 4c8fdc018b428c4b5f35215a1189d2cd55cd5888 (diff) | |
parent | 4e6f559b8c5f77924fdbe2e5abd9c6aa8efad13f (diff) | |
download | rneovim-1b0fd377aba3b4d076e4dbfb5adb96866a4982d1.tar.gz rneovim-1b0fd377aba3b4d076e4dbfb5adb96866a4982d1.tar.bz2 rneovim-1b0fd377aba3b4d076e4dbfb5adb96866a4982d1.zip |
Merge pull request #25767 from luukvbaal/signdel
feat(extmarks): add 'invalidate' property
Diffstat (limited to 'src/nvim/api/extmark.c')
-rw-r--r-- | src/nvim/api/extmark.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index 3f1745df40..aeecab6bd0 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -170,6 +170,13 @@ static Array extmark_to_array(const ExtmarkInfo *extmark, bool id, bool add_dict PUT(dict, "undo_restore", BOOLEAN_OBJ(false)); } + if (extmark->invalidate) { + PUT(dict, "invalidate", BOOLEAN_OBJ(true)); + } + if (extmark->invalid) { + PUT(dict, "invalid", BOOLEAN_OBJ(true)); + } + const Decoration *decor = &extmark->decor; if (decor->hl_id) { PUT(dict, "hl_group", hl_group_name(decor->hl_id, hl_name)); @@ -526,6 +533,9 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// - undo_restore : Restore the exact position of the mark /// if text around the mark was deleted and then restored by undo. /// Defaults to true. +/// - invalidate : boolean that indicates whether to hide the +/// extmark if the entirety of its range is deleted. If +/// "undo_restore" is false, the extmark is deleted instead. /// - priority: a priority value for the highlight group or sign /// attribute. For example treesitter highlighting uses a /// value of 100. @@ -759,8 +769,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer goto error; }); - bool end_right_gravity = opts->end_right_gravity; - size_t len = 0; if (!HAS_KEY(opts, set_extmark, spell)) { @@ -823,7 +831,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer // TODO(bfredl): synergize these two branches even more if (opts->ephemeral && decor_state.win && decor_state.win->w_buffer == buf) { - decor_add_ephemeral((int)line, (int)col, line2, col2, &decor, (uint64_t)ns_id, id); + decor_push_ephemeral((int)line, (int)col, line2, col2, &decor, (uint64_t)ns_id, id); } else { if (opts->ephemeral) { api_set_error(err, kErrorTypeException, "not yet implemented"); @@ -831,8 +839,9 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } extmark_set(buf, (uint32_t)ns_id, &id, (int)line, (colnr_T)col, line2, col2, - has_decor ? &decor : NULL, right_gravity, end_right_gravity, - !GET_BOOL_OR_TRUE(opts, set_extmark, undo_restore), err); + has_decor ? &decor : NULL, right_gravity, opts->end_right_gravity, + !GET_BOOL_OR_TRUE(opts, set_extmark, undo_restore), + opts->invalidate, err); if (ERROR_SET(err)) { goto error; } @@ -959,7 +968,7 @@ Integer nvim_buf_add_highlight(Buffer buffer, Integer ns_id, String hl_group, In extmark_set(buf, ns, NULL, (int)line, (colnr_T)col_start, end_line, (colnr_T)col_end, - &decor, true, false, false, NULL); + &decor, true, false, false, false, NULL); return ns_id; } @@ -1010,7 +1019,7 @@ void nvim_buf_clear_namespace(Buffer buffer, Integer ns_id, Integer line_start, /// redrawn buffer. |nvim_buf_set_extmark()| can be called to add marks /// on a per-window or per-lines basis. Use the `ephemeral` key to only /// use the mark for the current screen redraw (the callback will be called -/// again for the next redraw ). +/// again for the next redraw). /// /// Note: this function should not be called often. Rather, the callbacks /// themselves can be used to throttle unneeded callbacks. the `on_start` |