diff --git a/char.go b/char.go index 638199d..b64ebd5 100644 --- a/char.go +++ b/char.go @@ -16,7 +16,7 @@ const ( CharPrev = 16 CharBckSearch = 18 CharFwdSearch = 19 - CharTransform = 20 + CharTranspose = 20 CharCtrlW = 23 CharEsc = 27 CharEscapeEx = 91 @@ -28,5 +28,5 @@ const ( MetaNext MetaDelete MetaBackspace - MetaTransform + MetaTranspose ) diff --git a/operation.go b/operation.go index 8a7303e..5bd8aae 100644 --- a/operation.go +++ b/operation.go @@ -60,8 +60,8 @@ func (l *Operation) ioloop() { l.buf.Kill() case MetaNext: l.buf.MoveToNextWord() - case CharTransform: - l.buf.Transform() + case CharTranspose: + l.buf.Transpose() case MetaPrev: l.buf.MoveToPrevWord() case MetaDelete: diff --git a/runebuf.go b/runebuf.go index e32e2e4..bc77e67 100644 --- a/runebuf.go +++ b/runebuf.go @@ -123,7 +123,7 @@ func (r *RuneBuffer) Kill() { r.Refresh() } -func (r *RuneBuffer) Transform() { +func (r *RuneBuffer) Transpose() { if len(r.buf) < 2 { if len(r.buf) == 1 { r.idx++ @@ -133,6 +133,8 @@ func (r *RuneBuffer) Transform() { } if r.idx == 0 { r.idx = 1 + } else if r.idx >= len(r.buf) { + r.idx = len(r.buf) - 1 } r.buf[r.idx], r.buf[r.idx-1] = r.buf[r.idx-1], r.buf[r.idx] r.idx++ diff --git a/utils.go b/utils.go index a8d894c..3b52c42 100644 --- a/utils.go +++ b/utils.go @@ -52,8 +52,8 @@ func escapeKey(r rune) rune { r = MetaNext case 'd': r = MetaDelete - case CharTransform: - r = MetaTransform + case CharTranspose: + r = MetaTranspose case CharBackspace: r = MetaBackspace case CharEsc: