ReplaceText does DeleteText for given region, and then InsertText at given position (typically same as delSt but not necessarily). if matchCase is true, then the lexer.MatchCase function is called to match the case (upper / lower) of the new inserted text to that of the text being replaced. returns
(delSt, delEd, insPos lexer.Pos, insTxt string, matchCase bool)
| 1066 | // returns the Edit for the inserted text. |
| 1067 | // An Undo record is automatically saved depending on Undo.Off setting. |
| 1068 | func (ls *Lines) replaceText(delSt, delEd, insPos lexer.Pos, insTxt string, matchCase bool) *Edit { |
| 1069 | if matchCase { |
| 1070 | red := ls.region(delSt, delEd) |
| 1071 | cur := string(red.ToBytes()) |
| 1072 | insTxt = lexer.MatchCase(cur, insTxt) |
| 1073 | } |
| 1074 | if len(insTxt) > 0 { |
| 1075 | ls.deleteText(delSt, delEd) |
| 1076 | return ls.insertText(insPos, []byte(insTxt)) |
| 1077 | } |
| 1078 | return ls.deleteText(delSt, delEd) |
| 1079 | } |
| 1080 | |
| 1081 | ///////////////////////////////////////////////////////////////////////////// |
| 1082 | // Undo |
no test coverage detected