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

Method ReplaceText

texteditor/buffer.go:789–801  ·  view source on GitHub ↗

ReplaceText does DeleteText for given region, and then InsertText at given position (typically same as delSt but not necessarily), optionally emitting a signal after the insert. if matchCase is true, then the lexer.MatchCase function is called to match the case (upper / lower) of the new inserted te

(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool)

Source from the content-addressed store, hash-verified

787// case (upper / lower) of the new inserted text to that of the text being replaced.
788// returns the text.Edit for the inserted text.
789func (tb *Buffer) ReplaceText(delSt, delEd, insPos lexer.Pos, insTxt string, signal, matchCase bool) *text.Edit {
790 tbe := tb.Lines.ReplaceText(delSt, delEd, insPos, insTxt, matchCase)
791 if tbe == nil {
792 return tbe
793 }
794 if signal {
795 tb.signalMods() // todo: could be more specific?
796 }
797 if tb.Autosave {
798 go tb.autoSave()
799 }
800 return tbe
801}
802
803// savePosHistory saves the cursor position in history stack of cursor positions --
804// tracks across views -- returns false if position was on same line as last one saved

Callers 5

completeTextMethod · 0.95
correctTextMethod · 0.95
qReplaceReplaceMethod · 0.45
cursorTransposeMethod · 0.45
ReCaseSelectionMethod · 0.45

Calls 2

signalModsMethod · 0.95
autoSaveMethod · 0.95

Tested by

no test coverage detected