MCPcopy Create free account
hub / github.com/SolarLune/masterplan / MoveCaretBackOneWord

Method MoveCaretBackOneWord

gui.go:1603–1625  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1601}
1602
1603func (label *Label) MoveCaretBackOneWord() int {
1604
1605 start := label.Selection.CaretPos
1606 offset := 0
1607
1608 if start > 0 && (label.Text[start-1] == ' ' || label.Text[start-1] == '\n') {
1609 start--
1610 offset = 1
1611 }
1612
1613 next := label.LastIndexOfRunes(start, " \n")
1614
1615 if next < 0 {
1616 next = -label.Selection.CaretPos
1617 }
1618
1619 if next > 0 {
1620 next++
1621 }
1622
1623 return -(start - next + offset)
1624
1625}
1626
1627func (label *Label) Update() {
1628

Callers 1

UpdateMethod · 0.95

Calls 1

LastIndexOfRunesMethod · 0.95

Tested by

no test coverage detected