MCPcopy Create free account
hub / github.com/cogentcore/core / tabsToSpacesLine

Method tabsToSpacesLine

texteditor/text/lines.go:1751–1775  ·  view source on GitHub ↗

tabsToSpacesLine replaces tabs with spaces in the given line.

(ln int)

Source from the content-addressed store, hash-verified

1749
1750// tabsToSpacesLine replaces tabs with spaces in the given line.
1751func (ls *Lines) tabsToSpacesLine(ln int) {
1752 tabSz := ls.Options.TabSize
1753
1754 lr := ls.lines[ln]
1755 st := lexer.Pos{Ln: ln}
1756 ed := lexer.Pos{Ln: ln}
1757 i := 0
1758 for {
1759 if i >= len(lr) {
1760 break
1761 }
1762 r := lr[i]
1763 if r == '\t' {
1764 po := i % tabSz
1765 nspc := tabSz - po
1766 st.Ch = i
1767 ed.Ch = i + 1
1768 ls.replaceText(st, ed, st, indent.Spaces(1, nspc), ReplaceNoMatchCase)
1769 i += nspc
1770 lr = ls.lines[ln]
1771 } else {
1772 i++
1773 }
1774 }
1775}
1776
1777// tabsToSpaces replaces tabs with spaces over given region; end is *exclusive*.
1778func (ls *Lines) tabsToSpaces(start, end int) {

Callers 1

tabsToSpacesMethod · 0.95

Calls 2

replaceTextMethod · 0.95
SpacesFunction · 0.92

Tested by

no test coverage detected