MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / MoveActive

Method MoveActive

internal/app/notes.go:293–313  ·  view source on GitHub ↗

MoveActive shifts the active board by `delta` positions in the workspace order (negative = move left, positive = move right). Wraps around. The active index follows the moved board so the tab bar's `●` stays on it. Returns true if a swap happened.

(delta int)

Source from the content-addressed store, hash-verified

291// active index follows the moved board so the tab bar's `●` stays on it.
292// Returns true if a swap happened.
293func (w *Workspace) MoveActive(delta int) bool {
294 n := len(w.Boards)
295 if n < 2 || delta == 0 {
296 return false
297 }
298 src := w.ActiveIdx
299 dst := ((src+delta)%n + n) % n
300 if dst == src {
301 return false
302 }
303 b := w.Boards[src]
304 w.Boards = append(w.Boards[:src], w.Boards[src+1:]...)
305 // dst is in original numbering. After removing src, items at indices
306 // > src shifted left by one. Inserting at `dst` in the new list lands
307 // the moved item at the right final position in both directions and
308 // for the wrap-around cases.
309 tail := append([]*Board{b}, w.Boards[dst:]...)
310 w.Boards = append(w.Boards[:dst], tail...)
311 w.ActiveIdx = dst
312 return true
313}
314
315// CycleActive moves the active index by `delta`, wrapping around.
316func (w *Workspace) CycleActive(delta int) {

Callers 1

handleBoardKeyMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected