Switch folds from c-style array to std::vector
This commit is contained in:
@@ -29,7 +29,7 @@ struct SpanCursor {
|
||||
|
||||
SpanCursor(const std::vector<Span> &s) : spans(s) {}
|
||||
Highlight *get_highlight(uint32_t byte_offset) {
|
||||
for (int i = active.size() - 1; i >= 0; i--)
|
||||
for (int i = (int)active.size() - 1; i >= 0; i--)
|
||||
if (active[i]->end <= byte_offset)
|
||||
active.erase(active.begin() + i);
|
||||
while (index < spans.size() && spans[index].start <= byte_offset) {
|
||||
@@ -69,28 +69,27 @@ struct SpanCursor {
|
||||
};
|
||||
|
||||
struct Editor {
|
||||
const char *filename; // Filename of the editor
|
||||
Knot *root; // A rope
|
||||
std::shared_mutex knot_mtx; // A mutex
|
||||
std::shared_mutex span_mtx; // A mutex
|
||||
Coord cursor; // position of the cursor
|
||||
uint32_t cursor_preffered; // preffered visual column
|
||||
Coord selection; // position of the selection
|
||||
bool selection_active; // true if there is a selection
|
||||
Coord position; // Position of the editor
|
||||
Coord size; // Size of the editor
|
||||
Coord scroll; // Position of the scroll
|
||||
TSTree *tree; // Tree-sitter tree
|
||||
TSParser *parser; // Tree-sitter parser
|
||||
TSQuery *query; // Tree-sitter query
|
||||
const TSLanguage *language; // Tree-sitter language
|
||||
Queue<TSInputEdit> edit_queue; // Tree-sitter edit queue
|
||||
std::vector<Highlight> query_map; // Tree-sitter query map
|
||||
int *folded; // folded lines indexed by line number - cached form of
|
||||
// folded_node
|
||||
std::vector<Span> spans;
|
||||
const char *filename; // Filename of the editor
|
||||
Knot *root; // A rope
|
||||
std::shared_mutex knot_mtx; // A mutex
|
||||
std::shared_mutex span_mtx; // A mutex
|
||||
Coord cursor; // position of the cursor
|
||||
uint32_t cursor_preffered; // preffered visual column
|
||||
Coord selection; // position of the selection
|
||||
bool selection_active; // true if there is a selection
|
||||
Coord position; // Position of the editor
|
||||
Coord size; // Size of the editor
|
||||
Coord scroll; // Position of the scroll
|
||||
TSTree *tree; // Tree-sitter tree
|
||||
TSParser *parser; // Tree-sitter parser
|
||||
TSQuery *query; // Tree-sitter query
|
||||
const TSLanguage *language; // Tree-sitter language
|
||||
Queue<TSInputEdit> edit_queue; // Tree-sitter edit queue
|
||||
std::vector<Highlight> query_map; // Tree-sitter query map
|
||||
std::vector<int8_t> folded; // folded lines indexed by line number
|
||||
std::vector<Span> spans; // Highlighted spans
|
||||
std::map<uint32_t, bool> folded_node; // maps content hash to fold state
|
||||
// - built by tree-sitter
|
||||
// - built by tree-sitter helpers
|
||||
};
|
||||
|
||||
typedef struct TSLoad {
|
||||
|
||||
Reference in New Issue
Block a user