Use 64-bit integer for preview version

This commit is contained in:
Junegunn Choi 2020-10-24 16:55:55 +09:00
parent a1f06ae27f
commit 03c4f04246
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -43,7 +43,7 @@ const (
) )
type previewer struct { type previewer struct {
version int version int64
lines []string lines []string
offset int offset int
enabled bool enabled bool
@ -53,7 +53,7 @@ type previewer struct {
} }
type previewed struct { type previewed struct {
version int version int64
numLines int numLines int
offset int offset int
filled bool filled bool
@ -284,7 +284,7 @@ type previewRequest struct {
} }
type previewResult struct { type previewResult struct {
version int version int64
lines []string lines []string
offset int offset int
spinner string spinner string
@ -1752,7 +1752,7 @@ func (t *Terminal) Loop() {
if t.hasPreviewer() { if t.hasPreviewer() {
go func() { go func() {
version := 0 var version int64
for { for {
var items []*Item var items []*Item
var commandTemplate string var commandTemplate string
@ -1813,7 +1813,7 @@ func (t *Terminal) Loop() {
eofChan <- true eofChan <- true
}() }()
// Goroutine 2 periodically requests rendering // Goroutine 2 periodically requests rendering
go func(version int) { go func(version int64) {
lines := []string{} lines := []string{}
spinner := makeSpinner(t.unicode) spinner := makeSpinner(t.unicode)
spinnerIndex := -1 // Delay initial rendering by an extra tick spinnerIndex := -1 // Delay initial rendering by an extra tick
@ -1855,7 +1855,7 @@ func (t *Terminal) Loop() {
}(version) }(version)
} }
// Goroutine 3 is responsible for cancelling running preview command // Goroutine 3 is responsible for cancelling running preview command
go func(version int) { go func(version int64) {
timer := time.NewTimer(previewDelayed) timer := time.NewTimer(previewDelayed)
Loop: Loop:
for { for {
@ -1976,7 +1976,7 @@ func (t *Terminal) Loop() {
case reqPreviewRefresh: case reqPreviewRefresh:
t.printPreview() t.printPreview()
case reqPreviewDelayed: case reqPreviewDelayed:
t.previewer.version = value.(int) t.previewer.version = value.(int64)
t.printPreviewDelayed() t.printPreviewDelayed()
case reqPrintQuery: case reqPrintQuery:
exit(func() int { exit(func() int {