mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
feat(extmarks): add 'invalidate' property to extmarks
Problem: No way to have extmarks automatically removed when the range it is attached to is deleted. Solution: Add new 'invalidate' property that will hide a mark when the entirety of its range is deleted. When "undo_restore" is set to false, delete the mark from the buffer instead.
This commit is contained in:
@@ -78,17 +78,19 @@ typedef struct {
|
||||
#define MT_FLAG_ORPHANED (((uint16_t)1) << 3)
|
||||
#define MT_FLAG_HL_EOL (((uint16_t)1) << 4)
|
||||
#define MT_FLAG_NO_UNDO (((uint16_t)1) << 5)
|
||||
#define MT_FLAG_INVALIDATE (((uint16_t)1) << 6)
|
||||
#define MT_FLAG_INVALID (((uint16_t)1) << 7)
|
||||
|
||||
#define DECOR_LEVELS 4
|
||||
#define MT_FLAG_DECOR_OFFSET 6
|
||||
#define MT_FLAG_DECOR_OFFSET 8
|
||||
#define MT_FLAG_DECOR_MASK (((uint16_t)(DECOR_LEVELS - 1)) << MT_FLAG_DECOR_OFFSET)
|
||||
|
||||
// These _must_ be last to preserve ordering of marks
|
||||
#define MT_FLAG_RIGHT_GRAVITY (((uint16_t)1) << 14)
|
||||
#define MT_FLAG_LAST (((uint16_t)1) << 15)
|
||||
|
||||
#define MT_FLAG_EXTERNAL_MASK (MT_FLAG_DECOR_MASK | MT_FLAG_RIGHT_GRAVITY | \
|
||||
MT_FLAG_NO_UNDO | MT_FLAG_HL_EOL)
|
||||
#define MT_FLAG_EXTERNAL_MASK (MT_FLAG_DECOR_MASK | MT_FLAG_RIGHT_GRAVITY | MT_FLAG_HL_EOL \
|
||||
| MT_FLAG_NO_UNDO | MT_FLAG_INVALIDATE | MT_FLAG_INVALID)
|
||||
|
||||
// this is defined so that start and end of the same range have adjacent ids
|
||||
#define MARKTREE_END_FLAG ((uint64_t)1)
|
||||
@@ -132,17 +134,30 @@ static inline bool mt_no_undo(MTKey key)
|
||||
return key.flags & MT_FLAG_NO_UNDO;
|
||||
}
|
||||
|
||||
static inline bool mt_invalidate(MTKey key)
|
||||
{
|
||||
return key.flags & MT_FLAG_INVALIDATE;
|
||||
}
|
||||
|
||||
static inline bool mt_invalid(MTKey key)
|
||||
{
|
||||
return key.flags & MT_FLAG_INVALID;
|
||||
}
|
||||
|
||||
static inline uint8_t marktree_decor_level(MTKey key)
|
||||
{
|
||||
return (uint8_t)((key.flags&MT_FLAG_DECOR_MASK) >> MT_FLAG_DECOR_OFFSET);
|
||||
}
|
||||
|
||||
static inline uint16_t mt_flags(bool right_gravity, uint8_t decor_level, bool no_undo)
|
||||
static inline uint16_t mt_flags(bool right_gravity, bool hl_eol, bool no_undo, bool invalidate,
|
||||
uint8_t decor_level)
|
||||
{
|
||||
assert(decor_level < DECOR_LEVELS);
|
||||
return (uint16_t)((right_gravity ? MT_FLAG_RIGHT_GRAVITY : 0)
|
||||
| (decor_level << MT_FLAG_DECOR_OFFSET)
|
||||
| (no_undo ? MT_FLAG_NO_UNDO : 0));
|
||||
| (hl_eol ? MT_FLAG_HL_EOL : 0)
|
||||
| (no_undo ? MT_FLAG_NO_UNDO : 0)
|
||||
| (invalidate ? MT_FLAG_INVALIDATE : 0)
|
||||
| (decor_level << MT_FLAG_DECOR_OFFSET));
|
||||
}
|
||||
|
||||
typedef kvec_withinit_t(uint64_t, 4) Intersection;
|
||||
|
Reference in New Issue
Block a user