MCPcopy Index your code
hub / github.com/micro-editor/micro / SubWordLeft

Method SubWordLeft

internal/buffer/cursor.go:537–600  ·  view source on GitHub ↗

SubWordLeft moves the cursor one sub-word to the left

()

Source from the content-addressed store, hash-verified

535
536// SubWordLeft moves the cursor one sub-word to the left
537func (c *Cursor) SubWordLeft() {
538 if c.X == 0 {
539 c.Left()
540 return
541 }
542 c.Left()
543 if util.IsWhitespace(c.RuneUnder(c.X)) {
544 for util.IsWhitespace(c.RuneUnder(c.X)) {
545 if c.X == 0 {
546 return
547 }
548 c.Left()
549 }
550 c.Right()
551 return
552 }
553 if util.IsNonWordChar(c.RuneUnder(c.X)) && !util.IsWhitespace(c.RuneUnder(c.X)) {
554 for util.IsNonWordChar(c.RuneUnder(c.X)) && !util.IsWhitespace(c.RuneUnder(c.X)) {
555 if c.X == 0 {
556 return
557 }
558 c.Left()
559 }
560 c.Right()
561 return
562 }
563 if util.IsSubwordDelimiter(c.RuneUnder(c.X)) {
564 for util.IsSubwordDelimiter(c.RuneUnder(c.X)) {
565 if c.X == 0 {
566 return
567 }
568 c.Left()
569 }
570 if util.IsWhitespace(c.RuneUnder(c.X)) {
571 c.Right()
572 return
573 }
574 }
575 if c.X == 0 {
576 return
577 }
578 if util.IsUpperLetter(c.RuneUnder(c.X)) &&
579 util.IsUpperLetter(c.RuneUnder(c.X-1)) {
580 for util.IsUpperAlphanumeric(c.RuneUnder(c.X)) {
581 if c.X == 0 {
582 return
583 }
584 c.Left()
585 }
586 if !util.IsUpperAlphanumeric(c.RuneUnder(c.X)) {
587 c.Right()
588 }
589 } else {
590 for util.IsLowerAlphanumeric(c.RuneUnder(c.X)) {
591 if c.X == 0 {
592 return
593 }
594 c.Left()

Callers

nothing calls this directly

Calls 10

LeftMethod · 0.95
RuneUnderMethod · 0.95
RightMethod · 0.95
IsWhitespaceFunction · 0.92
IsNonWordCharFunction · 0.92
IsSubwordDelimiterFunction · 0.92
IsUpperLetterFunction · 0.92
IsUpperAlphanumericFunction · 0.92
IsLowerAlphanumericFunction · 0.92
IsAlphanumericFunction · 0.92

Tested by

no test coverage detected