diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-11-12 00:05:26 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-12 00:05:26 -0800 |
commit | db436d5277a605606ac92cfabe9e58d86f48f64e (patch) | |
tree | 944f02de6bfa974248700f4da1c881638fbde243 /src/nvim/mark_extended.c | |
parent | 0190de9aab53c0b82e648c51c5162d6377c6f341 (diff) | |
parent | a24eff0e2762657b4a82b2a7e78b4246f6462f95 (diff) | |
download | rneovim-db436d5277a605606ac92cfabe9e58d86f48f64e.tar.gz rneovim-db436d5277a605606ac92cfabe9e58d86f48f64e.tar.bz2 rneovim-db436d5277a605606ac92cfabe9e58d86f48f64e.zip |
Merge #11376 'extmark: renames, docs'
Diffstat (limited to 'src/nvim/mark_extended.c')
-rw-r--r-- | src/nvim/mark_extended.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/nvim/mark_extended.c b/src/nvim/mark_extended.c index 88348a8045..01745f484d 100644 --- a/src/nvim/mark_extended.c +++ b/src/nvim/mark_extended.c @@ -53,12 +53,12 @@ int extmark_set(buf_T *buf, uint64_t ns, uint64_t id, linenr_T lnum, colnr_T col, ExtmarkOp op) { - ExtendedMark *extmark = extmark_from_id(buf, ns, id); + Extmark *extmark = extmark_from_id(buf, ns, id); if (!extmark) { extmark_create(buf, ns, id, lnum, col, op); return true; } else { - ExtMarkLine *extmarkline = extmark->line; + ExtmarkLine *extmarkline = extmark->line; extmark_update(extmark, buf, ns, id, lnum, col, op, NULL); if (kb_size(&extmarkline->items) == 0) { kb_del(extmarklines, &buf->b_extlines, extmarkline); @@ -72,7 +72,7 @@ int extmark_set(buf_T *buf, uint64_t ns, uint64_t id, // Returns 0 on missing id int extmark_del(buf_T *buf, uint64_t ns, uint64_t id, ExtmarkOp op) { - ExtendedMark *extmark = extmark_from_id(buf, ns, id); + Extmark *extmark = extmark_from_id(buf, ns, id); if (!extmark) { return 0; } @@ -180,7 +180,7 @@ static void extmark_create(buf_T *buf, uint64_t ns, uint64_t id, } // Create or get a line - ExtMarkLine *extmarkline = extmarkline_ref(buf, lnum, true); + ExtmarkLine *extmarkline = extmarkline_ref(buf, lnum, true); // Create and put mark on the line extmark_put(col, id, extmarkline, ns); @@ -197,7 +197,7 @@ static void extmark_create(buf_T *buf, uint64_t ns, uint64_t id, // update the position of an extmark // to update while iterating pass the markitems itr -static void extmark_update(ExtendedMark *extmark, buf_T *buf, +static void extmark_update(Extmark *extmark, buf_T *buf, uint64_t ns, uint64_t id, linenr_T lnum, colnr_T col, ExtmarkOp op, kbitr_t(markitems) *mitr) @@ -207,10 +207,10 @@ static void extmark_update(ExtendedMark *extmark, buf_T *buf, u_extmark_update(buf, ns, id, extmark->line->lnum, extmark->col, lnum, col); } - ExtMarkLine *old_line = extmark->line; + ExtmarkLine *old_line = extmark->line; // Move the mark to a new line and update column if (old_line->lnum != lnum) { - ExtMarkLine *ref_line = extmarkline_ref(buf, lnum, true); + ExtmarkLine *ref_line = extmarkline_ref(buf, lnum, true); extmark_put(col, id, ref_line, ns); // Update the hashmap ExtmarkNs *ns_obj = pmap_get(uint64_t)(buf->b_extmark_ns, ns); @@ -234,7 +234,7 @@ static void extmark_update(ExtendedMark *extmark, buf_T *buf, } } -static int extmark_delete(ExtendedMark *extmark, +static int extmark_delete(Extmark *extmark, buf_T *buf, uint64_t ns, uint64_t id, @@ -250,7 +250,7 @@ static int extmark_delete(ExtendedMark *extmark, pmap_del(uint64_t)(ns_obj->map, id); // Remove the mark mark from the line - ExtMarkLine *extmarkline = extmark->line; + ExtmarkLine *extmarkline = extmark->line; kb_del(markitems, &extmarkline->items, *extmark); // Remove the line if there are no more marks in the line if (kb_size(&extmarkline->items) == 0) { @@ -261,7 +261,7 @@ static int extmark_delete(ExtendedMark *extmark, } // Lookup an extmark by id -ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) +Extmark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) { if (!buf->b_extmark_ns) { return NULL; @@ -270,7 +270,7 @@ ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) if (!ns_obj || !kh_size(ns_obj->map->table)) { return NULL; } - ExtMarkLine *extmarkline = pmap_get(uint64_t)(ns_obj->map, id); + ExtmarkLine *extmarkline = pmap_get(uint64_t)(ns_obj->map, id); if (!extmarkline) { return NULL; } @@ -285,8 +285,7 @@ ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id) } // Lookup an extmark by position -ExtendedMark *extmark_from_pos(buf_T *buf, - uint64_t ns, linenr_T lnum, colnr_T col) +Extmark *extmark_from_pos(buf_T *buf, uint64_t ns, linenr_T lnum, colnr_T col) { if (!buf->b_extmark_ns) { return NULL; @@ -842,7 +841,7 @@ static bool extmark_col_adjust_impl(buf_T *buf, linenr_T lnum, { bool marks_exist = false; - ExtMarkLine *extmarkline = extmarkline_ref(buf, lnum, false); + ExtmarkLine *extmarkline = extmarkline_ref(buf, lnum, false); if (!extmarkline) { return false; } @@ -968,7 +967,7 @@ void extmark_adjust(buf_T *buf, ExtmarkOp undo, bool end_temp) { - ExtMarkLine *_extline; + ExtmarkLine *_extline; // btree needs to be kept ordered to work, so far only :move requires this // 2nd call with end_temp = true unpack the lines from the temp position @@ -990,7 +989,7 @@ void extmark_adjust(buf_T *buf, // Careful! marks from deleted region can end up on en extisting extmarkline // that is goinig to be adjusted to the target position. linenr_T join_num = line1 - amount_after; - ExtMarkLine *joinline = (join_num > line2 + ExtmarkLine *joinline = (join_num > line2 ? extmarkline_ref(buf, join_num, false) : NULL); // extmark_adjust is already redoable, the copy should only be for undo @@ -1031,7 +1030,7 @@ bool extmark_copy_and_place(buf_T *buf, linenr_T u_lnum, colnr_T u_col, linenr_T p_lnum, colnr_T p_col, ExtmarkOp undo, bool delete, - ExtMarkLine *destline) + ExtmarkLine *destline) { bool marks_moved = false; @@ -1045,7 +1044,7 @@ bool extmark_copy_and_place(buf_T *buf, // marks within the same extmarkline. Too keep it simple, first delete all // items from the extmarkline and put them back in the right order. FOR_ALL_EXTMARKLINES(buf, l_lnum, u_lnum, { - kvec_t(ExtendedMark) temp_space = KV_INITIAL_VALUE; + kvec_t(Extmark) temp_space = KV_INITIAL_VALUE; bool same_line = extmarkline == destline; FOR_ALL_EXTMARKS_IN_LINE(extmarkline->items, (extmarkline->lnum > l_lnum) ? 0 : l_col, @@ -1068,7 +1067,7 @@ bool extmark_copy_and_place(buf_T *buf, }) if (same_line) { for (size_t i = 0; i < kv_size(temp_space); i++) { - ExtendedMark mark = kv_A(temp_space, i); + Extmark mark = kv_A(temp_space, i); extmark_put(p_col, mark.mark_id, extmarkline, mark.ns_id); } kv_destroy(temp_space); @@ -1087,10 +1086,10 @@ bool extmark_copy_and_place(buf_T *buf, } // Get reference to line in kbtree_t, allocating it if neccessary. -ExtMarkLine *extmarkline_ref(buf_T *buf, linenr_T lnum, bool put) +ExtmarkLine *extmarkline_ref(buf_T *buf, linenr_T lnum, bool put) { kbtree_t(extmarklines) *b = &buf->b_extlines; - ExtMarkLine t, **pp; + ExtmarkLine t, **pp; t.lnum = lnum; pp = kb_get(extmarklines, b, &t); @@ -1098,7 +1097,7 @@ ExtMarkLine *extmarkline_ref(buf_T *buf, linenr_T lnum, bool put) if (!put) { return NULL; } - ExtMarkLine *p = xcalloc(sizeof(ExtMarkLine), 1); + ExtmarkLine *p = xcalloc(sizeof(ExtmarkLine), 1); p->lnum = lnum; // p->items zero initialized kb_put(extmarklines, b, p); @@ -1108,7 +1107,7 @@ ExtMarkLine *extmarkline_ref(buf_T *buf, linenr_T lnum, bool put) return *pp; } -void extmarkline_free(ExtMarkLine *extmarkline) +void extmarkline_free(ExtmarkLine *extmarkline) { kb_destroy(markitems, (&extmarkline->items)); xfree(extmarkline); @@ -1118,9 +1117,9 @@ void extmarkline_free(ExtMarkLine *extmarkline) /// /// caller must ensure combination of id and ns_id isn't in use. void extmark_put(colnr_T col, uint64_t id, - ExtMarkLine *extmarkline, uint64_t ns) + ExtmarkLine *extmarkline, uint64_t ns) { - ExtendedMark t; + Extmark t; t.col = col; t.mark_id = id; t.line = extmarkline; |