Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 19c37d4

Browse files
committed
If the user fills the buffer, return.
1 parent a13c318 commit 19c37d4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

consolein/consolein.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (ci *ConsoleIn) ReadLine(max uint8) (string, error) {
219219
return "", err
220220
}
221221

222-
// Esc
222+
// Esc?
223223
if x == 27 {
224224
// remove the character from our text, and overwrite on the console
225225
for len(text) > 0 {
@@ -232,7 +232,7 @@ func (ci *ConsoleIn) ReadLine(max uint8) (string, error) {
232232
continue
233233
}
234234

235-
// Ctrl-N
235+
// Ctrl-N?
236236
if x == 14 {
237237
if offset >= 1 {
238238

@@ -253,7 +253,7 @@ func (ci *ConsoleIn) ReadLine(max uint8) (string, error) {
253253
continue
254254
}
255255

256-
// Ctrl-P ?
256+
// Ctrl-P?
257257
if x == 16 {
258258
if offset >= len(ci.history) {
259259
continue
@@ -274,7 +274,6 @@ func (ci *ConsoleIn) ReadLine(max uint8) (string, error) {
274274
}
275275

276276
// Ctrl-C ?
277-
//
278277
if x == 0x03 {
279278

280279
// Ctrl-C should only take effect at the start of the line.
@@ -302,7 +301,7 @@ func (ci *ConsoleIn) ReadLine(max uint8) (string, error) {
302301
if len(ci.history) == 0 {
303302
ci.history = append(ci.history, text)
304303
} else {
305-
// otherwise only add if different to previous entry
304+
// otherwise only add if different to previous entry.
306305
if text != ci.history[len(ci.history)-1] {
307306
ci.history = append(ci.history, text)
308307
}
@@ -325,12 +324,13 @@ func (ci *ConsoleIn) ReadLine(max uint8) (string, error) {
325324
continue
326325
}
327326

328-
// If the user has entered the maximum then we'll
329-
// avoid further input
327+
// If the user has entered the maximum then we'll say their
328+
// input-time is over now.
330329
if len(text) >= int(max) {
331-
continue
330+
break
332331
}
333-
// Otherwise if it was a printable character we'll keep it.
332+
333+
// Finally if it was a printable character we'll keep it.
334334
if unicode.IsPrint(rune(x)) {
335335
fmt.Printf("%c", x)
336336
text += string(x)

0 commit comments

Comments
 (0)