IsValid ensures that at least some text is represented and the sizes of Text and Render slices are the same, and that the first render info is non-nil
()
| 70 | // IsValid ensures that at least some text is represented and the sizes of |
| 71 | // Text and Render slices are the same, and that the first render info is non-nil |
| 72 | func (sr *Span) IsValid() error { |
| 73 | if len(sr.Text) == 0 { |
| 74 | return errors.New("core.Text: Text is empty") |
| 75 | } |
| 76 | if len(sr.Text) != len(sr.Render) { |
| 77 | return fmt.Errorf("core.Text: Render length %v != Text length %v for text: %v", len(sr.Render), len(sr.Text), string(sr.Text)) |
| 78 | } |
| 79 | return sr.Render[0].HasNil() |
| 80 | } |
| 81 | |
| 82 | // SizeHV computes the size of the text span from the first char to the last |
| 83 | // position, which is valid for purely horizontal or vertical text lines -- |
no test coverage detected