@@ -27,6 +27,9 @@ const (
27
27
defaultCharLimit = 400
28
28
defaultMaxHeight = 99
29
29
defaultMaxWidth = 500
30
+
31
+ // XXX: in v2, make max lines dynamic and default max lines configurable.
32
+ maxLines = 10000
30
33
)
31
34
32
35
// Internal messages for clipboard operations.
@@ -290,13 +293,13 @@ func New() Model {
290
293
style : & blurredStyle ,
291
294
FocusedStyle : focusedStyle ,
292
295
BlurredStyle : blurredStyle ,
293
- cache : memoization.NewMemoCache [line , [][]rune ](defaultMaxHeight ),
296
+ cache : memoization.NewMemoCache [line , [][]rune ](maxLines ),
294
297
EndOfBufferCharacter : ' ' ,
295
298
ShowLineNumbers : true ,
296
299
Cursor : cur ,
297
300
KeyMap : DefaultKeyMap ,
298
301
299
- value : make ([][]rune , minHeight , defaultMaxHeight ),
302
+ value : make ([][]rune , minHeight , maxLines ),
300
303
focus : false ,
301
304
col : 0 ,
302
305
row : 0 ,
@@ -360,9 +363,8 @@ func (m *Model) insertRunesFromUserInput(runes []rune) {
360
363
// whatnot.
361
364
runes = m .san ().Sanitize (runes )
362
365
363
- var availSpace int
364
366
if m .CharLimit > 0 {
365
- availSpace = m .CharLimit - m .Length ()
367
+ availSpace : = m .CharLimit - m .Length ()
366
368
// If the char limit's been reached, cancel.
367
369
if availSpace <= 0 {
368
370
return
@@ -393,9 +395,9 @@ func (m *Model) insertRunesFromUserInput(runes []rune) {
393
395
lines = append (lines , runes [lstart :])
394
396
}
395
397
396
- // Obey the maximum height limit.
397
- if m . MaxHeight > 0 && len (m .value )+ len (lines )- 1 > m . MaxHeight {
398
- allowedHeight := max (0 , m . MaxHeight - len (m .value )+ 1 )
398
+ // Obey the maximum line limit.
399
+ if maxLines > 0 && len (m .value )+ len (lines )- 1 > maxLines {
400
+ allowedHeight := max (0 , maxLines - len (m .value )+ 1 )
399
401
lines = lines [:allowedHeight ]
400
402
}
401
403
@@ -590,11 +592,7 @@ func (m *Model) Blur() {
590
592
591
593
// Reset sets the input to its default state with no input.
592
594
func (m * Model ) Reset () {
593
- startCap := m .MaxHeight
594
- if startCap <= 0 {
595
- startCap = defaultMaxHeight
596
- }
597
- m .value = make ([][]rune , minHeight , startCap )
595
+ m .value = make ([][]rune , minHeight , maxLines )
598
596
m .col = 0
599
597
m .row = 0
600
598
m .viewport .GotoTop ()
0 commit comments