mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-26 02:40:30 +00:00
Sanitize inputs to insert and remove
This commit is contained in:
parent
57a992c4a3
commit
3ed77dbb2e
1 changed files with 3 additions and 0 deletions
|
|
@ -117,6 +117,7 @@ func (eh *EventHandler) Insert(start Loc, textStr string) {
|
|||
|
||||
// InsertBytes creates an insert text event and executes it
|
||||
func (eh *EventHandler) InsertBytes(start Loc, text []byte) {
|
||||
start = clamp(start, eh.buf.LineArray)
|
||||
e := &TextEvent{
|
||||
C: *eh.cursors[eh.active],
|
||||
EventType: TextEventInsert,
|
||||
|
|
@ -167,6 +168,8 @@ func (eh *EventHandler) InsertBytes(start Loc, text []byte) {
|
|||
|
||||
// Remove creates a remove text event and executes it
|
||||
func (eh *EventHandler) Remove(start, end Loc) {
|
||||
start = clamp(start, eh.buf.LineArray)
|
||||
end = clamp(end, eh.buf.LineArray)
|
||||
e := &TextEvent{
|
||||
C: *eh.cursors[eh.active],
|
||||
EventType: TextEventRemove,
|
||||
|
|
|
|||
Loading…
Reference in a new issue