• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tstack / lnav / 19553931481-2697

20 Nov 2025 10:54PM UTC coverage: 68.864%. Remained the same
19553931481-2697

push

github

tstack
[files] some more files panel polishing

8 of 17 new or added lines in 2 files covered. (47.06%)

1 existing line in 1 file now uncovered.

51097 of 74200 relevant lines covered (68.86%)

431705.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.62
/src/plain_text_source.cc
1
/**
2
 * Copyright (c) 2022, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29

30
#include "plain_text_source.hh"
31

32
#include "base/itertools.hh"
33
#include "config.h"
34
#include "document.sections.hh"
35
#include "scn/scan.h"
36

37
static std::vector<plain_text_source::text_line>
38
to_text_line(const std::vector<attr_line_t>& lines)
×
39
{
40
    file_off_t off = 0;
×
41

42
    return lines | lnav::itertools::map([&off](const auto& elem) {
×
43
               auto retval = plain_text_source::text_line{
×
44
                   off,
45
                   elem,
46
               };
47

48
               off += elem.length() + 1;
×
49
               return retval;
×
50
           });
×
51
}
52

53
plain_text_source::plain_text_source(const string_fragment& text)
×
54
{
55
    size_t start = 0;
×
56

57
    for (const auto& line : text.split_lines()) {
×
58
        this->tds_lines.emplace_back(start, attr_line_t::from_ansi_frag(line));
×
59
        start += line.length();
×
60
    }
61
    this->tds_longest_line = this->compute_longest_line();
×
62
}
63

64
plain_text_source::plain_text_source(const std::vector<std::string>& text_lines)
×
65
{
66
    this->replace_with(text_lines);
×
67
}
68

69
plain_text_source::plain_text_source(const std::vector<attr_line_t>& text_lines)
×
70
    : tds_lines(to_text_line(text_lines))
×
71
{
72
    this->tds_longest_line = this->compute_longest_line();
×
73
}
74

75
plain_text_source&
76
plain_text_source::replace_with(const attr_line_t& text_lines)
72✔
77
{
78
    this->tds_lines.clear();
72✔
79
    this->tds_doc_sections = lnav::document::discover_metadata(text_lines);
72✔
80
    file_off_t off = 0;
72✔
81
    auto lines = text_lines.split_lines();
72✔
82
    while (!lines.empty() && lines.back().empty()) {
72✔
83
        lines.pop_back();
×
84
    }
85
    for (auto& line : lines) {
20,279✔
86
        auto line_len = line.al_string.size() + 1;
20,207✔
87
        this->tds_lines.emplace_back(off, std::move(line));
20,207✔
88
        off += line_len;
20,207✔
89
    }
90
    this->tds_longest_line = this->compute_longest_line();
72✔
91
    if (this->tss_view != nullptr) {
72✔
92
        this->tss_view->set_selection(0_vl);
53✔
93
        this->tss_view->set_needs_update();
53✔
94
    }
95
    return *this;
72✔
96
}
72✔
97

98
plain_text_source&
99
plain_text_source::replace_with_mutable(attr_line_t& text_lines,
23✔
100
                                        text_format_t tf)
101
{
102
    this->tds_text_format = tf;
23✔
103
    this->tds_lines.clear();
23✔
104
    this->tds_doc_sections
105
        = lnav::document::discover(text_lines).with_text_format(tf).perform();
23✔
106
    file_off_t off = 0;
23✔
107
    auto lines = text_lines.split_lines();
23✔
108
    while (!lines.empty() && lines.back().empty()) {
23✔
109
        lines.pop_back();
×
110
    }
111
    for (auto& line : lines) {
8,061✔
112
        auto line_len = line.length() + 1;
8,038✔
113
        this->tds_lines.emplace_back(off, std::move(line));
8,038✔
114
        off += line_len;
8,038✔
115
    }
116
    this->tds_longest_line = this->compute_longest_line();
23✔
117
    if (this->tss_view != nullptr) {
23✔
118
        this->tss_view->set_selection(0_vl);
4✔
119
        this->tss_view->set_needs_update();
4✔
120
    }
121
    return *this;
23✔
122
}
23✔
123

124
plain_text_source&
125
plain_text_source::replace_with(const std::vector<std::string>& text_lines)
×
126
{
127
    file_off_t off = 0;
×
128
    for (const auto& str : text_lines) {
×
129
        this->tds_lines.emplace_back(off, attr_line_t::from_ansi_str(str));
×
130
        off += str.length() + 1;
×
131
    }
132
    this->tds_longest_line = this->compute_longest_line();
×
133
    if (this->tss_view != nullptr) {
×
NEW
134
        this->tss_view->set_selection(0_vl);
×
UNCOV
135
        this->tss_view->set_needs_update();
×
136
    }
137
    return *this;
×
138
}
139

140
plain_text_source&
141
plain_text_source::replace_with(const std::vector<attr_line_t>& text_lines)
21✔
142
{
143
    file_off_t off = 0;
21✔
144
    this->tds_lines.clear();
21✔
145
    for (const auto& al : text_lines) {
454✔
146
        this->tds_lines.emplace_back(off, al);
433✔
147
        off += al.length() + 1;
433✔
148
    }
149
    this->tds_longest_line = this->compute_longest_line();
21✔
150
    if (this->tss_view != nullptr) {
21✔
151
        this->tss_view->set_selection(0_vl);
21✔
152
        this->tss_view->set_needs_update();
21✔
153
    }
154
    return *this;
21✔
155
}
156

157
void
158
plain_text_source::clear()
455✔
159
{
160
    this->tds_lines.clear();
455✔
161
    this->tds_longest_line = 0;
455✔
162
    this->tds_text_format = text_format_t::TF_UNKNOWN;
455✔
163
    if (this->tss_view != nullptr) {
455✔
164
        this->tss_view->set_needs_update();
377✔
165
    }
166
}
455✔
167

168
plain_text_source&
169
plain_text_source::truncate_to(size_t max_lines)
×
170
{
171
    while (this->tds_lines.size() > max_lines) {
×
172
        this->tds_lines.pop_back();
×
173
    }
174
    if (this->tss_view != nullptr) {
×
175
        this->tss_view->set_needs_update();
×
176
    }
177
    return *this;
×
178
}
179

180
size_t
181
plain_text_source::text_line_width(textview_curses& curses)
5,319✔
182
{
183
    return this->tds_longest_line;
5,319✔
184
}
185

186
line_info
187
plain_text_source::text_value_for_line(textview_curses& tc,
7,524✔
188
                                       int row,
189
                                       std::string& value_out,
190
                                       text_sub_source::line_flags_t flags)
191
{
192
    value_out = this->tds_lines[row].tl_value.get_string();
7,524✔
193
    this->tds_line_indent_size = 0;
7,524✔
194
    for (const auto& ch : value_out) {
22,283✔
195
        if (ch == ' ') {
21,029✔
196
            this->tds_line_indent_size += 1;
14,759✔
197
        } else if (ch == '\t') {
6,270✔
198
            do {
199
                this->tds_line_indent_size += 1;
×
200
            } while (this->tds_line_indent_size % 8);
×
201
        } else {
202
            break;
6,270✔
203
        }
204
    }
205

206
    return {};
7,524✔
207
}
208

209
void
210
plain_text_source::text_attrs_for_line(textview_curses& tc,
7,524✔
211
                                       int line,
212
                                       string_attrs_t& value_out)
213
{
214
    value_out = this->tds_lines[line].tl_value.get_attrs();
7,524✔
215
    if (this->tds_reverse_selection && tc.is_selectable()
×
216
        && tc.get_selection() == line)
7,524✔
217
    {
218
        value_out.emplace_back(line_range{0, -1},
×
219
                               VC_STYLE.value(text_attrs::with_reverse()));
×
220
    }
221
    for (const auto& indent : this->tds_doc_sections.m_indents) {
10,096✔
222
        if (indent < this->tds_line_indent_size) {
2,572✔
223
            auto guide_lr = line_range{
224
                (int) indent,
465✔
225
                (int) (indent + 1),
465✔
226
                line_range::unit::codepoint,
227
            };
465✔
228
            value_out.emplace_back(guide_lr,
465✔
229
                                   VC_BLOCK_ELEM.value(block_elem_t{
930✔
230
                                       L'\u258f', role_t::VCR_INDENT_GUIDE}));
231
        }
232
    }
233
}
7,524✔
234

235
size_t
236
plain_text_source::text_size_for_line(textview_curses& tc,
×
237
                                      int row,
238
                                      text_sub_source::line_flags_t flags)
239
{
240
    return this->tds_lines[row].tl_value.length();
×
241
}
242

243
text_format_t
244
plain_text_source::get_text_format() const
5,440✔
245
{
246
    return this->tds_text_format;
5,440✔
247
}
248

249
size_t
250
plain_text_source::compute_longest_line()
116✔
251
{
252
    size_t retval = 0;
116✔
253
    for (auto& iter : this->tds_lines) {
28,794✔
254
        retval = std::max(retval, (size_t) iter.tl_value.length());
28,678✔
255
    }
256
    return retval;
116✔
257
}
258

259
std::optional<vis_line_t>
260
plain_text_source::line_for_offset(file_off_t off) const
6✔
261
{
262
    struct cmper {
263
        bool operator()(const file_off_t& lhs, const text_line& rhs) const
264
        {
265
            return lhs < rhs.tl_offset;
266
        }
267

268
        bool operator()(const text_line& lhs, const file_off_t& rhs) const
57✔
269
        {
270
            return lhs.tl_offset < rhs;
57✔
271
        }
272
    };
273

274
    if (this->tds_lines.empty()) {
6✔
275
        return std::nullopt;
×
276
    }
277

278
    log_trace("line_for_offset(%lld)", off);
6✔
279
    auto iter = std::lower_bound(
6✔
280
        this->tds_lines.begin(), this->tds_lines.end(), off, cmper{});
281
    if (iter == this->tds_lines.end()) {
6✔
282
        if (this->tds_lines.back().contains_offset(off)) {
×
283
            return std::make_optional(
×
284
                vis_line_t(std::distance(this->tds_lines.end() - 1, iter)));
×
285
        }
286
        return std::nullopt;
×
287
    }
288

289
    if (!iter->contains_offset(off) && iter != this->tds_lines.begin()) {
6✔
290
        log_trace("  lower_bound (%lld) does not contain offset",
2✔
291
                  iter->tl_offset);
292
        --iter;
2✔
293
    }
294

295
    auto retval = vis_line_t(std::distance(this->tds_lines.begin(), iter));
12✔
296
    log_trace("  retval=%d", (int) retval);
6✔
297
    return retval;
6✔
298
}
299

300
void
301
plain_text_source::text_crumbs_for_line(int line,
2✔
302
                                        std::vector<breadcrumb::crumb>& crumbs)
303
{
304
    const auto initial_size = crumbs.size();
2✔
305
    const auto& tl = this->tds_lines[line];
2✔
306

307
    this->tds_doc_sections.m_sections_tree.visit_overlapping(
4✔
308
        tl.tl_offset,
2✔
309
        tl.tl_offset + tl.tl_value.length(),
2✔
310
        [&crumbs, initial_size, meta = &this->tds_doc_sections, this](
2✔
311
            const auto& iv) {
312
            auto path = crumbs | lnav::itertools::skip(initial_size)
12✔
313
                | lnav::itertools::map(&breadcrumb::crumb::c_key)
8✔
314
                | lnav::itertools::append(iv.value);
4✔
315
            crumbs.emplace_back(
8✔
316
                iv.value,
4✔
317
                [meta, path]() { return meta->possibility_provider(path); },
12✔
318
                [this, meta, path](const auto& key) {
8✔
319
                    auto curr_node = lnav::document::hier_node::lookup_path(
×
320
                        meta->m_sections_root.get(), path);
×
321
                    if (!curr_node) {
×
322
                        return;
×
323
                    }
324
                    auto* parent_node = curr_node.value()->hn_parent;
×
325

326
                    if (parent_node == nullptr) {
×
327
                        return;
×
328
                    }
329
                    key.match(
×
330
                        [this, parent_node](const std::string& str) {
×
331
                            auto sib_iter
332
                                = parent_node->hn_named_children.find(str);
×
333
                            if (sib_iter
×
334
                                == parent_node->hn_named_children.end()) {
×
335
                                return;
×
336
                            }
337
                            this->line_for_offset(sib_iter->second->hn_start) |
×
338
                                [this](const auto new_top) {
×
339
                                    this->tss_view->set_selection(new_top);
×
340
                                    if (this->tss_view->is_selectable()) {
×
341
                                        this->tss_view->set_top(new_top - 2_vl,
×
342
                                                                false);
343
                                    }
344
                                };
345
                        },
346
                        [this, parent_node](size_t index) {
×
347
                            if (index >= parent_node->hn_children.size()) {
×
348
                                return;
×
349
                            }
350
                            auto sib = parent_node->hn_children[index].get();
×
351
                            this->line_for_offset(sib->hn_start) |
×
352
                                [this](const auto new_top) {
×
353
                                    this->tss_view->set_selection(new_top);
×
354
                                    if (this->tss_view->is_selectable()) {
×
355
                                        this->tss_view->set_top(new_top - 2_vl,
×
356
                                                                false);
357
                                    }
358
                                };
359
                        });
360
                });
361
        });
4✔
362

363
    auto path = crumbs | lnav::itertools::skip(initial_size)
4✔
364
        | lnav::itertools::map(&breadcrumb::crumb::c_key);
4✔
365
    auto node = lnav::document::hier_node::lookup_path(
2✔
366
        this->tds_doc_sections.m_sections_root.get(), path);
2✔
367

368
    if (node && !node.value()->hn_children.empty()) {
2✔
369
        auto poss_provider = [curr_node = node.value()]() {
1✔
370
            std::vector<breadcrumb::possibility> retval;
1✔
371
            for (const auto& child : curr_node->hn_named_children) {
2✔
372
                retval.emplace_back(child.first);
1✔
373
            }
374
            return retval;
1✔
375
        };
376
        auto path_performer = [this, curr_node = node.value()](
2✔
377
                                  const breadcrumb::crumb::key_t& value) {
378
            value.match(
×
379
                [this, curr_node](const std::string& str) {
×
380
                    auto child_iter = curr_node->hn_named_children.find(str);
×
381
                    if (child_iter != curr_node->hn_named_children.end()) {
×
382
                        this->line_for_offset(child_iter->second->hn_start) |
×
383
                            [this](const auto new_top) {
×
384
                                this->tss_view->set_selection(new_top);
×
385
                            };
386
                    }
387
                },
×
388
                [this, curr_node](size_t index) {
×
389
                    auto* child = curr_node->hn_children[index].get();
×
390
                    this->line_for_offset(child->hn_start) |
×
391
                        [this](const auto new_top) {
×
392
                            this->tss_view->set_selection(new_top);
×
393
                        };
394
                });
×
395
        };
1✔
396
        crumbs.emplace_back(
1✔
397
            "", "\u22ef", std::move(poss_provider), std::move(path_performer));
1✔
398
        crumbs.back().c_expected_input = node.value()->hn_named_children.empty()
2✔
399
            ? breadcrumb::crumb::expected_input_t::index
1✔
400
            : breadcrumb::crumb::expected_input_t::index_or_exact;
401
    }
402
}
2✔
403

404
std::optional<vis_line_t>
405
plain_text_source::row_for_anchor(const std::string& id)
5✔
406
{
407
    std::optional<vis_line_t> retval;
5✔
408

409
    if (this->tds_doc_sections.m_sections_root == nullptr) {
5✔
410
        return retval;
×
411
    }
412

413
    const auto& meta = this->tds_doc_sections;
5✔
414

415
    auto is_ptr = startswith(id, "#/");
5✔
416
    if (is_ptr) {
5✔
417
        auto hier_sf = string_fragment::from_str(id).consume_n(2).value();
×
418
        std::vector<lnav::document::section_key_t> path;
×
419

420
        while (!hier_sf.empty()) {
×
421
            auto comp_pair = hier_sf.split_when(string_fragment::tag1{'/'});
×
422
            auto scan_res
423
                = scn::scan_value<int64_t>(comp_pair.first.to_string_view());
×
424
            if (scan_res && scan_res->range().empty()) {
×
425
                path.emplace_back(scan_res->value());
×
426
            } else {
427
                stack_buf allocator;
×
428
                path.emplace_back(
×
429
                    json_ptr::decode(comp_pair.first, allocator).to_string());
×
430
            }
431
            hier_sf = comp_pair.second;
×
432
        }
433

434
        auto lookup_res = lnav::document::hier_node::lookup_path(
×
435
            meta.m_sections_root.get(), path);
×
436
        if (lookup_res) {
×
437
            retval = this->line_for_offset(lookup_res.value()->hn_start);
×
438
        }
439

440
        return retval;
×
441
    }
442

443
    lnav::document::hier_node::depth_first(
5✔
444
        meta.m_sections_root.get(),
445
        [this, &id, &retval](const lnav::document::hier_node* node) {
67✔
446
            for (const auto& child_pair : node->hn_named_children) {
114✔
447
                const auto& child_anchor = to_anchor_string(child_pair.first);
51✔
448

449
                if (child_anchor != id) {
51✔
450
                    continue;
47✔
451
                }
452

453
                retval = this->line_for_offset(child_pair.second->hn_start);
4✔
454
                break;
4✔
455
            }
51✔
456
        });
67✔
457

458
    return retval;
5✔
459
}
460

461
std::unordered_set<std::string>
462
plain_text_source::get_anchors()
×
463
{
464
    std::unordered_set<std::string> retval;
×
465

466
    lnav::document::hier_node::depth_first(
×
467
        this->tds_doc_sections.m_sections_root.get(),
468
        [&retval](const lnav::document::hier_node* node) {
×
469
            for (const auto& child_pair : node->hn_named_children) {
×
470
                retval.emplace(to_anchor_string(child_pair.first));
×
471
            }
472
        });
×
473

474
    return retval;
×
475
}
×
476

477
std::optional<std::string>
478
plain_text_source::anchor_for_row(vis_line_t vl)
4✔
479
{
480
    std::optional<std::string> retval;
4✔
481

482
    if (vl > (ssize_t) this->tds_lines.size()
4✔
483
        || this->tds_doc_sections.m_sections_root == nullptr)
4✔
484
    {
485
        return retval;
×
486
    }
487

488
    const auto& tl = this->tds_lines[vl];
4✔
489
    auto& md = this->tds_doc_sections;
4✔
490
    auto path_for_line = md.path_for_range(
491
        tl.tl_offset, tl.tl_offset + tl.tl_value.al_string.length());
4✔
492

493
    if (path_for_line.empty()) {
4✔
494
        return std::nullopt;
1✔
495
    }
496

497
    if ((path_for_line.size() == 1
3✔
498
         || this->tds_text_format == text_format_t::TF_MARKDOWN)
2✔
499
        && path_for_line.back().is<std::string>())
5✔
500
    {
501
        return to_anchor_string(path_for_line.back().get<std::string>());
2✔
502
    }
503

504
    auto comps
505
        = path_for_line | lnav::itertools::map([](const auto& elem) {
2✔
506
              return elem.match(
507
                  [](const std::string& str) {
×
508
                      stack_buf allocator;
1✔
509
                      return json_ptr::encode(str, allocator).to_string();
2✔
510
                  },
1✔
511
                  [](size_t index) { return fmt::to_string(index); });
5✔
512
          });
1✔
513

514
    return fmt::format(FMT_STRING("#/{}"),
4✔
515
                       fmt::join(comps.begin(), comps.end(), "/"));
2✔
516
}
4✔
517

518
std::optional<vis_line_t>
519
plain_text_source::adjacent_anchor(vis_line_t vl, direction dir)
2✔
520
{
521
    if (vl > (ssize_t) this->tds_lines.size()
2✔
522
        || this->tds_doc_sections.m_sections_root == nullptr)
2✔
523
    {
524
        return std::nullopt;
×
525
    }
526

527
    const auto& tl = this->tds_lines[vl];
2✔
528
    auto path_for_line = this->tds_doc_sections.path_for_range(
529
        tl.tl_offset, tl.tl_offset + tl.tl_value.al_string.length());
2✔
530

531
    log_trace("adjacent_anchor: curr path = %s",
2✔
532
              fmt::format(FMT_STRING("{}"), path_for_line).c_str());
533
    const auto& md = this->tds_doc_sections;
2✔
534
    if (path_for_line.empty()) {
2✔
535
        auto neighbors_res = md.m_sections_root->line_neighbors(vl);
1✔
536
        if (!neighbors_res) {
1✔
537
            return std::nullopt;
×
538
        }
539

540
        switch (dir) {
1✔
541
            case direction::prev: {
×
542
                if (neighbors_res->cnr_previous) {
×
543
                    return this->line_for_offset(
×
544
                        neighbors_res->cnr_previous.value()->hn_start);
×
545
                }
546
                break;
×
547
            }
548
            case direction::next: {
1✔
549
                if (neighbors_res->cnr_next) {
1✔
550
                    return this->line_for_offset(
×
551
                        neighbors_res->cnr_next.value()->hn_start);
×
552
                }
553
                if (!md.m_sections_root->hn_children.empty()) {
1✔
554
                    return this->line_for_offset(
1✔
555
                        md.m_sections_root->hn_children[0]->hn_start);
2✔
556
                }
557
                break;
×
558
            }
559
        }
560
        return std::nullopt;
×
561
    }
562

563
    auto last_key = path_for_line.back();
1✔
564
    path_for_line.pop_back();
1✔
565

566
    auto parent_opt = lnav::document::hier_node::lookup_path(
1✔
567
        md.m_sections_root.get(), path_for_line);
1✔
568
    if (!parent_opt) {
1✔
569
        log_trace("  no parent");
×
570
        return std::nullopt;
×
571
    }
572
    const auto* parent = parent_opt.value();
1✔
573

574
    auto child_hn = parent->lookup_child(last_key);
1✔
575
    if (!child_hn) {
1✔
576
        // XXX "should not happen"
577
        return std::nullopt;
×
578
    }
579

580
    auto neighbors_res = parent->child_neighbors(
3✔
581
        child_hn.value(), tl.tl_offset + tl.tl_value.al_string.length() + 1);
1✔
582
    if (!neighbors_res) {
1✔
583
        log_trace("no neighbors");
×
584
        return std::nullopt;
×
585
    }
586

587
    if (neighbors_res->cnr_previous && last_key.is<std::string>()) {
1✔
588
        auto neighbor_sub
589
            = neighbors_res->cnr_previous.value()->lookup_child(last_key);
1✔
590
        if (neighbor_sub) {
1✔
591
            log_trace("  loading previous child");
×
592
            neighbors_res->cnr_previous = neighbor_sub;
×
593
        }
594
    }
595

596
    if (neighbors_res->cnr_next && last_key.is<std::string>()) {
1✔
597
        auto neighbor_sub
598
            = neighbors_res->cnr_next.value()->lookup_child(last_key);
1✔
599
        if (neighbor_sub) {
1✔
600
            log_trace("  loading next child");
×
601
            neighbors_res->cnr_next = neighbor_sub;
×
602
        }
603
    }
604

605
    switch (dir) {
1✔
606
        case direction::prev: {
×
607
            if (neighbors_res->cnr_previous) {
×
608
                return this->line_for_offset(
×
609
                    neighbors_res->cnr_previous.value()->hn_start);
×
610
            }
611
            break;
×
612
        }
613
        case direction::next: {
1✔
614
            if (neighbors_res->cnr_next) {
1✔
615
                log_trace("  next offset %lld",
1✔
616
                          neighbors_res->cnr_next.value()->hn_start);
617
                return this->line_for_offset(
1✔
618
                    neighbors_res->cnr_next.value()->hn_start);
1✔
619
            }
620
            break;
×
621
        }
622
    }
623

624
    return std::nullopt;
×
625
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc