Ran go fmt *.go on all sources

This commit is contained in:
Luke I. Wilson
2021-04-04 13:15:31 -05:00
parent e115855491
commit 3982628653
11 changed files with 78 additions and 79 deletions

View File

@@ -62,7 +62,6 @@ type Buffer interface {
// the last rune before the line delimiter.
ClampLineCol(line, col int) (int, int)
// LineColToPos returns the index of the byte at line, col. If line is less than
// zero, or more than the number of available lines, the function will panic. If
// col is less than zero, the function will panic. If col is greater than the

View File

@@ -23,14 +23,14 @@ func (c *Colorscheme) GetStyle(s Syntax) tcell.Style {
}
}
return tcell.StyleDefault; // No value for Default; use default style.
return tcell.StyleDefault // No value for Default; use default style.
}
type RegexpRegion struct {
Start *regexp.Regexp
End *regexp.Regexp // Should be "$" by default
Skip *regexp.Regexp // Optional
Error *regexp.Regexp // Optional
End *regexp.Regexp // Should be "$" by default
Skip *regexp.Regexp // Optional
Error *regexp.Regexp // Optional
Specials []*regexp.Regexp // Optional (nil or zero len)
}
@@ -97,9 +97,9 @@ func (h *Highlighter) updateLines(startLine, endLine int) {
bytes := h.Buffer.Slice(startLine, 0, endLine, endCol)
for k, v := range h.Language.Rules {
var indexes [][]int // [][2]int
var indexes [][]int // [][2]int
if k.End != nil && k.End.String() != "$" { // If this range might be a multiline range...
endIndexes := k.End.FindAllIndex(bytes, -1) // Attempt to find every ending match
endIndexes := k.End.FindAllIndex(bytes, -1) // Attempt to find every ending match
startIndexes := k.Start.FindAllIndex(bytes, -1) // Attempt to find every starting match
// ...
_ = endIndexes
@@ -111,9 +111,9 @@ func (h *Highlighter) updateLines(startLine, endLine int) {
if indexes != nil {
for i := range indexes {
startLine, startCol := h.Buffer.PosToLineCol(indexes[i][0] + startPos)
endLine, endCol := h.Buffer.PosToLineCol(indexes[i][1]-1 + startPos)
endLine, endCol := h.Buffer.PosToLineCol(indexes[i][1] - 1 + startPos)
match := Match { startCol, endLine, endCol, v }
match := Match{startCol, endLine, endCol, v}
h.lineMatches[startLine] = append(h.lineMatches[startLine], match) // Unsorted
}
@@ -138,7 +138,7 @@ func (h *Highlighter) UpdateInvalidatedLines(startLine, endLine int) {
// Keep endLine clamped
if endLine >= len(h.lineMatches) {
endLine = len(h.lineMatches)-1
endLine = len(h.lineMatches) - 1
}
// Move endLine back to first line at or before endLine with invalidated changes

View File

@@ -57,7 +57,7 @@ func (b *RopeBuffer) LineColToPos(line, col int) int {
// delimiter. line starts from zero. Data returned may or may not be a copy: do not
// write it.
func (b *RopeBuffer) Line(line int) []byte {
pos := b.getLineStartPos(line)
pos := b.getLineStartPos(line)
bytes := 0
_rope := (*rope.Node)(b)
@@ -99,7 +99,7 @@ func (b *RopeBuffer) Line(line int) []byte {
func (b *RopeBuffer) Slice(startLine, startCol, endLine, endCol int) []byte {
endPos := b.LineColToPos(endLine, endCol)
if length := (*rope.Node)(b).Len(); endPos >= length {
endPos = length-1
endPos = length - 1
}
return (*rope.Node)(b).Slice(b.LineColToPos(startLine, startCol), endPos+1)
}
@@ -164,7 +164,7 @@ func (b *RopeBuffer) getLineStartPos(line int) int {
if line > 0 {
_rope.IndexAllFunc(0, _rope.Len(), []byte{'\n'}, func(idx int) bool {
line--
pos = idx + 1 // idx+1 = start of line after delimiter
pos = idx + 1 // idx+1 = start of line after delimiter
if line <= 0 { // If pos is now the start of the line we're searching for...
return true // Stop indexing
}
@@ -213,7 +213,7 @@ func (b *RopeBuffer) RunesInLineWithDelim(line int) int {
count++ // Add the '\r' we previously thought was part of the delim.
}
}
// Respect Utf-8 codepoint boundaries
_, size := utf8.DecodeRune(data[i:])
i += size
@@ -257,7 +257,7 @@ func (b *RopeBuffer) RunesInLine(line int) int {
}
}
count++
// Respect Utf-8 codepoint boundaries
_, size := utf8.DecodeRune(data[i:])
i += size
@@ -275,8 +275,8 @@ func (b *RopeBuffer) RunesInLine(line int) int {
func (b *RopeBuffer) ClampLineCol(line, col int) (int, int) {
if line < 0 {
line = 0
} else if lines := b.Lines()-1; line > lines {
line = lines
} else if lines := b.Lines() - 1; line > lines {
line = lines
}
if col < 0 {

View File

@@ -19,7 +19,7 @@ func TestRopePosToLineCol(t *testing.T) {
t.Errorf("Expected startCol == 0, got %v", startCol)
}
endPos := buf.Len()-1
endPos := buf.Len() - 1
endLine, endCol := buf.PosToLineCol(endPos)
t.Logf("endPos = %v", endPos)
if endLine != 3 {