From 55677ddc4637664c8ef034e5c91f79fae8a97396 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 15 Nov 2019 18:21:45 +0100 Subject: Add new marktree data structure for storing marks This is inspired by Atom's "marker index" data structure to efficiently adjust marks to text insertions deletions, but uses a wide B-tree (derived from kbtree) to keep the nesting level down. --- src/nvim/map.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/map.h') diff --git a/src/nvim/map.h b/src/nvim/map.h index 75ab64cca4..fec91ac0c2 100644 --- a/src/nvim/map.h +++ b/src/nvim/map.h @@ -53,6 +53,8 @@ MAP_DECLS(String, handle_T) #define map_del(T, U) map_##T##_##U##_del #define map_clear(T, U) map_##T##_##U##_clear +#define map_size(map) ((map)->table->size) + #define pmap_new(T) map_new(T, ptr_t) #define pmap_free(T) map_free(T, ptr_t) #define pmap_get(T) map_get(T, ptr_t) -- cgit From ca1a00edd6d6345b848a28d077d6a192528f811e Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 14 Jan 2020 12:45:09 +0100 Subject: extmarks/bufhl: reimplement using new marktree data structure Add new "splice" interface for tracking buffer changes at the byte level. This will later be reused for byte-resolution buffer updates. (Implementation has been started, but using undocumented "_on_bytes" option now as interface hasn't been finalized). Use this interface to improve many edge cases of extmark adjustment. Changed tests indicate previously incorrect behavior. Adding tests for more edge cases will be follow-up work (overlaps on_bytes tests) Don't consider creation/deletion of marks an undoable event by itself. This behavior was never documented, and imposes complexity for little gain. Add nvim__buf_add_decoration temporary API for direct access to the new implementation. This should be refactored into a proper API for decorations, probably involving a huge dict. fixes #11598 --- src/nvim/map.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/nvim/map.h') diff --git a/src/nvim/map.h b/src/nvim/map.h index fec91ac0c2..761938776d 100644 --- a/src/nvim/map.h +++ b/src/nvim/map.h @@ -4,9 +4,9 @@ #include #include "nvim/map_defs.h" +#include "nvim/mark_extended_defs.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" -#include "nvim/bufhl_defs.h" #include "nvim/highlight_defs.h" #if defined(__NetBSD__) @@ -38,6 +38,18 @@ MAP_DECLS(int, int) MAP_DECLS(cstr_t, ptr_t) MAP_DECLS(ptr_t, ptr_t) MAP_DECLS(uint64_t, ptr_t) +MAP_DECLS(uint64_t, ssize_t) +MAP_DECLS(uint64_t, uint64_t) + +// NB: this is the only way to define a struct both containing and contained +// in a map... +typedef struct ExtmarkNs { // For namespacing extmarks + Map(uint64_t, uint64_t) *map; // For fast lookup + uint64_t free_id; // For automatically assigning id's +} ExtmarkNs; + +MAP_DECLS(uint64_t, ExtmarkNs) +MAP_DECLS(uint64_t, ExtmarkItem) MAP_DECLS(handle_T, ptr_t) MAP_DECLS(String, MsgpackRpcRequestHandler) MAP_DECLS(HlEntry, int) -- cgit From 48a869dc6d29514e943070da9f22f702f5179826 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 20 Jan 2020 19:29:12 +0100 Subject: shed biking: it's always extmarks, never marks extended --- src/nvim/map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/map.h') diff --git a/src/nvim/map.h b/src/nvim/map.h index 761938776d..0ad7865bf0 100644 --- a/src/nvim/map.h +++ b/src/nvim/map.h @@ -4,7 +4,7 @@ #include #include "nvim/map_defs.h" -#include "nvim/mark_extended_defs.h" +#include "nvim/extmark_defs.h" #include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/highlight_defs.h" -- cgit