WordAt returns the word around a given location in the buffer
(loc Loc)
| 664 | |
| 665 | // WordAt returns the word around a given location in the buffer |
| 666 | func (b *Buffer) WordAt(loc Loc) []byte { |
| 667 | if len(b.LineBytes(loc.Y)) == 0 || !util.IsWordChar(b.RuneAt(loc)) { |
| 668 | return []byte{} |
| 669 | } |
| 670 | |
| 671 | start := loc |
| 672 | end := loc.Move(1, b) |
| 673 | |
| 674 | for start.X > 0 && util.IsWordChar(b.RuneAt(start.Move(-1, b))) { |
| 675 | start.X-- |
| 676 | } |
| 677 | |
| 678 | lineLen := util.CharacterCount(b.LineBytes(loc.Y)) |
| 679 | for end.X < lineLen && util.IsWordChar(b.RuneAt(end)) { |
| 680 | end.X++ |
| 681 | } |
| 682 | |
| 683 | return b.Substr(start, end) |
| 684 | } |
| 685 | |
| 686 | // Shared returns if there are other buffers with the same file as this buffer |
| 687 | func (b *Buffer) Shared() bool { |
nothing calls this directly
no test coverage detected