MCPcopy Create free account
hub / github.com/cogentcore/core / CursorToHistoryPrev

Method CursorToHistoryPrev

texteditor/nav.go:122–143  ·  view source on GitHub ↗

CursorToHistoryPrev moves cursor to previous position on history list -- returns true if moved

()

Source from the content-addressed store, hash-verified

120// CursorToHistoryPrev moves cursor to previous position on history list --
121// returns true if moved
122func (ed *Editor) CursorToHistoryPrev() bool {
123 if ed.NumLines == 0 || ed.Buffer == nil {
124 ed.CursorPos = lexer.PosZero
125 return false
126 }
127 sz := len(ed.Buffer.posHistory)
128 if sz == 0 {
129 return false
130 }
131 ed.posHistoryIndex--
132 if ed.posHistoryIndex < 0 {
133 ed.posHistoryIndex = 0
134 return false
135 }
136 ed.posHistoryIndex = min(sz-1, ed.posHistoryIndex)
137 pos := ed.Buffer.posHistory[ed.posHistoryIndex]
138 ed.CursorPos = ed.Buffer.ValidPos(pos)
139 ed.cursorMovedEvent()
140 ed.scrollCursorToCenterIfHidden()
141 ed.renderCursor(true)
142 return true
143}
144
145// CursorToHistoryNext moves cursor to previous position on history list --
146// returns true if moved

Callers 1

keyInputMethod · 0.95

Calls 4

cursorMovedEventMethod · 0.95
renderCursorMethod · 0.95
ValidPosMethod · 0.80

Tested by

no test coverage detected