|
44 | 44 | #include "base/itertools.hh" |
45 | 45 | #include "base/map_util.hh" |
46 | 46 | #include "base/math_util.hh" |
| 47 | +#include "base/string_util.hh" |
47 | 48 | #include "bound_tags.hh" |
48 | 49 | #include "config.h" |
49 | 50 | #include "data_scanner.hh" |
@@ -186,15 +187,24 @@ textfile_sub_source::text_value_for_line(textview_curses& tc, |
186 | 187 | if (meta.m_valid_utf && meta.m_has_ansi) { |
187 | 188 | scrub_ansi_string(value_out, &this->tss_plain_line_attrs); |
188 | 189 | } |
189 | | - for (const auto& ch : value_out) { |
190 | | - if (ch == ' ') { |
191 | | - this->tss_line_indent_size += 1; |
192 | | - } else if (ch == '\t') { |
193 | | - do { |
194 | | - this->tss_line_indent_size += 1; |
195 | | - } while (this->tss_line_indent_size % 8); |
196 | | - } else { |
197 | | - break; |
| 190 | + this->tss_line_indent_size = compute_indent_size(value_out); |
| 191 | + if (this->tss_line_indent_size == 0 && value_out.empty()) { |
| 192 | + for (auto next = line + 1; |
| 193 | + next < (ssize_t) lfo->lfo_filter_state.tfs_index.size(); |
| 194 | + ++next) |
| 195 | + { |
| 196 | + auto next_ll |
| 197 | + = lf->begin() + lfo->lfo_filter_state.tfs_index[next]; |
| 198 | + auto next_result = lf->read_line(next_ll, read_opts); |
| 199 | + if (next_result.isOk()) { |
| 200 | + auto next_sbr = next_result.unwrap(); |
| 201 | + auto next_str = to_string(next_sbr); |
| 202 | + this->tss_line_indent_size |
| 203 | + = compute_indent_size(next_str) + 1; |
| 204 | + if (!next_str.empty()) { |
| 205 | + break; |
| 206 | + } |
| 207 | + } |
198 | 208 | } |
199 | 209 | } |
200 | 210 | if (lf->has_line_metadata() && this->tas_display_time_offset) { |
|
0 commit comments