appendTextLineMarkup appends one line of new text to end of lines, using insert, and appending a LF at the end of the line if it doesn't already have one. User-supplied markup is used. Returns the edit region.
(text []byte, markup []byte)
| 716 | // insert, and appending a LF at the end of the line if it doesn't already |
| 717 | // have one. User-supplied markup is used. Returns the edit region. |
| 718 | func (ls *Lines) appendTextLineMarkup(text []byte, markup []byte) *Edit { |
| 719 | ed := ls.endPos() |
| 720 | sz := len(text) |
| 721 | addLF := true |
| 722 | if sz > 0 { |
| 723 | if text[sz-1] == '\n' { |
| 724 | addLF = false |
| 725 | } |
| 726 | } |
| 727 | efft := text |
| 728 | if addLF { |
| 729 | efft = make([]byte, sz+1) |
| 730 | copy(efft, text) |
| 731 | efft[sz] = '\n' |
| 732 | } |
| 733 | tbe := ls.insertText(ed, efft) |
| 734 | ls.Markup[tbe.Reg.Start.Ln] = markup |
| 735 | return tbe |
| 736 | } |
| 737 | |
| 738 | ///////////////////////////////////////////////////////////////////////////// |
| 739 | // Edits |
no test coverage detected