Skip to content
Myr

Fix `--preview-window follow` not working correctly with wrapping (contd.)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent c338df0 · Browse files · 1 file+11 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−6 removed

  • other:+11 added−6 removed

1 file+11 added−6 removed

modified:src/terminal.go+11 added-6 removed
1248 unmodified lines
1249 }1250 if opts.WrapSign != nil {1251 t.wrapSign = *opts.WrapSign1252 }1253 t.wrapSign, t.wrapSignWidth = t.processTabs([]rune(t.wrapSign), 0)1253 t.wrapSign, t.wrapSignWidth = t.processTabsStr(t.wrapSign, 0)1254 if opts.Scrollbar == nil {1255 if t.unicode && t.borderWidth == 1 {1256 t.scrollbar = "│"1257 } else {
320 unmodified lines
1578 Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, false, line, line, true, preTask, nil)1579 })1580 t.wrap = wrap1581 }1582 _, promptLen := t.processTabs([]rune(trimmed), 0)1582 _, promptLen := t.processTabsStr(trimmed, 0)15831584 return output, promptLen1585}1586
2574 unmodified lines
4161// ansiLineWidth computes the display width of a string, skipping ANSI escape sequences.4162// prefixWidth is the visual offset where the content starts (e.g. wrap sign width for4163// continuation lines), used for correct tab stop alignment.4164func (t *Terminal) ansiLineWidth(line string, prefixWidth int) int {4165 line = strings.TrimSuffix(line, "\n")4166 trimmed, _, _ := extractColor(line, nil, nil)4166 _, width := t.processTabs([]rune(trimmed), prefixWidth)4167 _, width := t.processTabsStr(trimmed, prefixWidth)4168 return width - prefixWidth4169}41704171func (t *Terminal) wordWrapAnsiLine(line string, maxWidth int, wrapSignWidth int) []string {
325 unmodified lines
4497 t.pwindow.Move(0, pos)4498 t.pwindow.CPrint(tui.ColInfo.WithAttr(tui.Reverse), message)4499}45004500func (t *Terminal) processTabs(runes []rune, prefixWidth int) (string, int) {4501func (t *Terminal) processTabsStr(input string, prefixWidth int) (string, int) {4502 var strbuf strings.Builder4503 l := prefixWidth4503 gr := uniseg.NewGraphemes(string(runes))4504 gr := uniseg.NewGraphemes(input)4505 for gr.Next() {4506 rs := gr.Runes()4507 str := string(rs)4508 var w int
8 unmodified lines
4517 }4518 return strbuf.String(), l4519}45204521func (t *Terminal) processTabs(runes []rune, prefixWidth int) (string, int) {4522 return t.processTabsStr(string(runes), prefixWidth)4523}45244525func (t *Terminal) printAll() {4526 t.resizeWindows(t.forcePreview, true)4527 t.printList()4528 t.printPrompt()
808 unmodified lines
53375338 // NOTE: Unlike in click-header, we don't use --delimiter here, since we're5339 // only interested in the word, not nth. Does this make sense?5340 trimmed, _, _ := extractColor(t.footer[clickFooterLine], nil, nil)5336 trimmed, _ = t.processTabs([]rune(trimmed), 0)5341 trimmed, _ = t.processTabsStr(trimmed, 0)5342 words := Tokenize(trimmed, Delimiter{})5343 colNum := t.clickFooterColumn - 15344 for _, token := range words {5345 prefixWidth := int(token.prefixLength)
2293 unmodified lines