File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -481,8 +481,8 @@ func visualLength(runes []rune) int {
481
481
482
482
// histroryAt unlocks the terminal and relocks it while calling History.At.
483
483
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.
486
486
if idx < 0 || idx >= t .History .Len () {
487
487
return "" , false
488
488
}
@@ -827,7 +827,7 @@ func (t *Terminal) readLine() (line string, err error) {
827
827
if lineOk {
828
828
if t .echo {
829
829
t .historyIndex = - 1
830
- t .historyAdd (line ) // so this can output without deadlock.
830
+ t .historyAdd (line )
831
831
}
832
832
if lineIsPasted {
833
833
err = ErrPasteIndicator
@@ -994,7 +994,7 @@ func (s *stRingBuffer) Len() int {
994
994
// false.
995
995
func (s * stRingBuffer ) At (n int ) string {
996
996
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 ))
998
998
}
999
999
index := s .head - n
1000
1000
if index < 0 {
You can’t perform that action at this time.
0 commit comments