UpdateDiff computes the diff between the diff base and the buffer content. The update may be performed synchronously or asynchronously. If an asynchronous update is already pending when UpdateDiff is called, UpdateDiff does not schedule another update.
()
| 1377 | // If an asynchronous update is already pending when UpdateDiff is called, |
| 1378 | // UpdateDiff does not schedule another update. |
| 1379 | func (b *Buffer) UpdateDiff() { |
| 1380 | if b.updateDiffTimer != nil { |
| 1381 | return |
| 1382 | } |
| 1383 | |
| 1384 | lineCount := b.LinesNum() |
| 1385 | if b.diffBaseLineCount > lineCount { |
| 1386 | lineCount = b.diffBaseLineCount |
| 1387 | } |
| 1388 | |
| 1389 | if lineCount < 1000 { |
| 1390 | b.updateDiff(true) |
| 1391 | } else if lineCount < 30000 { |
| 1392 | b.updateDiffTimer = time.AfterFunc(500*time.Millisecond, func() { |
| 1393 | b.updateDiffTimer = nil |
| 1394 | b.updateDiff(false) |
| 1395 | screen.Redraw() |
| 1396 | }) |
| 1397 | } else { |
| 1398 | // Don't compute diffs for very large files |
| 1399 | b.diffLock.Lock() |
| 1400 | b.diff = make(map[int]DiffStatus) |
| 1401 | b.diffLock.Unlock() |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | // SetDiffBase sets the text that is used as the base for diffing the buffer content |
| 1406 | func (b *Buffer) SetDiffBase(diffBase []byte) { |
no test coverage detected