robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. Keyesfix(extmarks): undo-redo of a mark explicitly moved during an edit #412522546741d1b

master
1.7 KiB82 linesraw
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5
6#include "klib/kvec.h"
7#include "nvim/extmark_defs.h"  // IWYU pragma: keep
8#include "nvim/macros_defs.h"
9#include "nvim/marktree_defs.h"
10#include "nvim/pos_defs.h"
11#include "nvim/types_defs.h"  // IWYU pragma: keep
12
13EXTERN int curbuf_splice_pending INIT( = 0);
14
15typedef kvec_t(MTPair) ExtmarkInfoArray;
16
17// delete the columns between mincol and endcol
18typedef struct {
19  int start_row;
20  colnr_T start_col;
21  int old_row;
22  colnr_T old_col;
23  int new_row;
24  colnr_T new_col;
25  bcount_t start_byte;
26  bcount_t old_byte;
27  bcount_t new_byte;
28} ExtmarkSplice;
29
30// adjust marks after :move operation
31typedef struct {
32  int start_row;
33  int start_col;
34  int extent_row;
35  int extent_col;
36  int new_row;
37  int new_col;
38  bcount_t start_byte;
39  bcount_t extent_byte;
40  bcount_t new_byte;
41} ExtmarkMove;
42
43// extmark was updated
44typedef struct {
45  uint64_t mark;  // raw mark id of the marktree
46  int undo_row;
47  colnr_T undo_col;
48  int redo_row;   // -1: nothing to redo (the mark was not explicitly moved).
49  colnr_T redo_col;
50  bool invalidated;
51} ExtmarkSavePos;
52
53typedef enum {
54  kExtmarkSplice,
55  kExtmarkMove,
56  kExtmarkUpdate,
57  kExtmarkSavePos,
58  kExtmarkClear,
59} UndoObjectType;
60
61// TODO(bfredl): if possible unify these with marktree flags,
62// so it is possible to filter extmarks directly on top-level flags
63typedef enum {
64  kExtmarkNone = 0x1,
65  kExtmarkSign = 0x2,
66  kExtmarkSignHL = 0x4,
67  kExtmarkVirtText = 0x8,
68  kExtmarkVirtLines = 0x10,
69  kExtmarkHighlight = 0x20,
70} ExtmarkType;
71
72// TODO(bfredl): reduce the number of undo action types
73struct undo_object {
74  UndoObjectType type;
75  union {
76    ExtmarkSplice splice;
77    ExtmarkMove move;
78    ExtmarkSavePos savepos;
79  } data;
80};
81
82#include "extmark.h.generated.h"