MCPcopy
hub / github.com/micro-editor/micro / WordLeft

Method WordLeft

internal/buffer/cursor.go:443–474  ·  view source on GitHub ↗

WordLeft moves the cursor one word to the left

()

Source from the content-addressed store, hash-verified

441
442// WordLeft moves the cursor one word to the left
443func (c *Cursor) WordLeft() {
444 if c.X == 0 {
445 c.Left()
446 return
447 }
448 c.Left()
449 for util.IsWhitespace(c.RuneUnder(c.X)) {
450 if c.X == 0 {
451 return
452 }
453 c.Left()
454 }
455 if util.IsNonWordChar(c.RuneUnder(c.X)) && !util.IsWhitespace(c.RuneUnder(c.X)) &&
456 util.IsNonWordChar(c.RuneUnder(c.X-1)) {
457 for util.IsNonWordChar(c.RuneUnder(c.X)) && !util.IsWhitespace(c.RuneUnder(c.X)) {
458 if c.X == 0 {
459 return
460 }
461 c.Left()
462 }
463 c.Right()
464 return
465 }
466 c.Left()
467 for util.IsWordChar(c.RuneUnder(c.X)) {
468 if c.X == 0 {
469 return
470 }
471 c.Left()
472 }
473 c.Right()
474}
475
476// SubWordRight moves the cursor one sub-word to the right
477func (c *Cursor) SubWordRight() {

Callers

nothing calls this directly

Calls 6

LeftMethod · 0.95
RuneUnderMethod · 0.95
RightMethod · 0.95
IsWhitespaceFunction · 0.92
IsNonWordCharFunction · 0.92
IsWordCharFunction · 0.92

Tested by

no test coverage detected