Skip to content

Commit d864f8c

Browse files
committed
Fix linter errors
1 parent 8c4f174 commit d864f8c

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

completion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ func (c *CompletionManager) update() {
108108
}
109109

110110
func deleteBreakLineCharacters(s string) string {
111-
s = strings.Replace(s, "\n", "", -1)
112-
s = strings.Replace(s, "\r", "", -1)
111+
s = strings.ReplaceAll(s, "\n", "")
112+
s = strings.ReplaceAll(s, "\r", "")
113113
return s
114114
}
115115

history.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ func (h *History) DeleteAll() {
8585
h.selected = 0
8686
}
8787

88+
const defaultHistorySize = 500
89+
8890
// NewHistory returns new history object.
8991
func NewHistory() *History {
9092
return &History{
9193
histories: []string{},
9294
tmp: []string{""},
9395
selected: 0,
94-
size: 500,
96+
size: defaultHistorySize,
9597
}
9698
}

history_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestHistoryClear(t *testing.T) {
1313
histories: []string{"foo"},
1414
tmp: []string{"foo", ""},
1515
selected: 1,
16-
size: 1000,
16+
size: defaultHistorySize,
1717
}
1818
if !reflect.DeepEqual(expected, h) {
1919
t.Errorf("Should be %#v, but got %#v", expected, h)
@@ -27,7 +27,7 @@ func TestHistoryAdd(t *testing.T) {
2727
histories: []string{"echo 1"},
2828
tmp: []string{"echo 1", ""},
2929
selected: 1,
30-
size: 1000,
30+
size: defaultHistorySize,
3131
}
3232
if !reflect.DeepEqual(h, expected) {
3333
t.Errorf("Should be %v, but got %v", expected, h)

prompt.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ type Prompt struct {
5757
executeOnEnterCallback ExecuteOnEnterCallback
5858
skipClose bool
5959
completionReset bool
60-
parseHistoryCommands bool
6160
}
6261

6362
// UserInput is the struct that contains the user input context.

renderer.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,7 @@ func (r *Renderer) getMultilinePrefix(prefix string) string {
307307
var spaceCount int
308308
var dotCount int
309309
var nonSpaceCharSeen bool
310-
for {
311-
if len(prefix) == 0 {
312-
break
313-
}
310+
for len(prefix) != 0 {
314311
char, size := utf8.DecodeLastRuneInString(prefix)
315312
prefix = prefix[:len(prefix)-size]
316313
charWidth := istrings.GetRuneWidth(char)

writer_vt100.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var _ io.StringWriter = &VT100Writer{}
1616

1717
// Write to write safety byte array by removing control sequences.
1818
func (w *VT100Writer) Write(data []byte) (int, error) {
19-
w.WriteRaw(bytes.Replace(data, []byte{0x1b}, []byte{'?'}, -1))
19+
w.WriteRaw(bytes.ReplaceAll(data, []byte{0x1b}, []byte{'?'}))
2020
return len(data), nil
2121
}
2222

@@ -198,7 +198,7 @@ func (w *VT100Writer) SetTitle(title string) {
198198
},
199199
}
200200
for i := range patterns {
201-
titleBytes = bytes.Replace(titleBytes, patterns[i].from, patterns[i].to, -1)
201+
titleBytes = bytes.ReplaceAll(titleBytes, patterns[i].from, patterns[i].to)
202202
}
203203

204204
w.WriteRaw([]byte{0x1b, ']', '2', ';'})

0 commit comments

Comments
 (0)