Skip to content

Commit 5e07c15

Browse files
committed
Review updates
1 parent ba6dd5c commit 5e07c15

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

terminal.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ func visualLength(runes []rune) int {
481481

482482
// histroryAt unlocks the terminal and relocks it while calling History.At.
483483
func (t *Terminal) historyAt(idx int) (string, bool) {
484-
t.lock.Unlock()
485-
defer t.lock.Lock()
484+
t.lock.Unlock() // Unlock to avoid deadlock if History methods use the output writer.
485+
defer t.lock.Lock() // panic in At (or Len) protection.
486486
if idx < 0 || idx >= t.History.Len() {
487487
return "", false
488488
}
@@ -827,7 +827,7 @@ func (t *Terminal) readLine() (line string, err error) {
827827
if lineOk {
828828
if t.echo {
829829
t.historyIndex = -1
830-
t.historyAdd(line) // so this can output without deadlock.
830+
t.historyAdd(line)
831831
}
832832
if lineIsPasted {
833833
err = ErrPasteIndicator
@@ -994,7 +994,7 @@ func (s *stRingBuffer) Len() int {
994994
// false.
995995
func (s *stRingBuffer) At(n int) string {
996996
if n < 0 || n >= s.size {
997-
panic(fmt.Sprintf("stRingBuffer: index [%d] out of range [0,%d)", n, s.size))
997+
panic(fmt.Sprintf("term: history index [%d] out of range [0,%d)", n, s.size))
998998
}
999999
index := s.head - n
10001000
if index < 0 {

0 commit comments

Comments
 (0)