MCPcopy Create free account
hub / github.com/cogentcore/core / appendTextLineMarkup

Method appendTextLineMarkup

texteditor/text/lines.go:718–736  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
718func (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

Callers 1

AppendTextLineMarkupMethod · 0.95

Calls 2

endPosMethod · 0.95
insertTextMethod · 0.95

Tested by

no test coverage detected