Skip to content

Commit

Permalink
Merge pull request #191 from noborus/add-tail-section
Browse files Browse the repository at this point in the history
Clarification of the role of the lastSection move
  • Loading branch information
noborus authored May 19, 2022
2 parents 138a08c + 0a791e7 commit 9f20a13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 11 additions & 0 deletions oviewer/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@ func (root *Root) TailSync() {
root.ViewSync()
}

// tailSection moves to the last section
// and adjusts to its original position.
func (root *Root) tailSection() {
moved := root.Doc.topLN - root.Doc.lastSectionPosNum
root.lastSection()
if moved > 0 && (root.Doc.topLN+moved) < root.Doc.BufEndNum() {
root.moveLine(root.Doc.topLN + moved)
}
root.Doc.lastSectionPosNum = root.Doc.topLN
}

// prepareStartX prepares startX.
func (root *Root) prepareStartX() {
root.startX = 0
Expand Down
6 changes: 1 addition & 5 deletions oviewer/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ func (root *Root) follow() {

root.skipDraw = false
if root.Doc.FollowSection {
moved := root.Doc.topLN - root.Doc.lastSectionPosNum
root.lastSection()
if moved > 0 && (root.Doc.topLN+moved) < root.Doc.BufEndNum() {
root.moveLine(root.Doc.topLN + moved)
}
root.tailSection()
} else {
root.TailSync()
}
Expand Down
1 change: 0 additions & 1 deletion oviewer/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ func (root *Root) lastSection() {
return
}
n = (n - root.Doc.firstLine()) + root.Doc.SectionStartPosition
m.lastSectionPosNum = n
root.moveLine(n)
}

Expand Down

0 comments on commit 9f20a13

Please sign in to comment.