3 Star 0 Fork 0

mirrors_influxdata/go-prompt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
emacs_test.go 741 Bytes
一键复制 编辑 原始数据 按行查看 历史
c-bata 提交于 2018-06-22 01:11 . Support CJK and Cyrillic characters
package prompt
import "testing"
func TestEmacsKeyBindings(t *testing.T) {
buf := NewBuffer()
buf.InsertText("abcde", false, true)
if buf.cursorPosition != len("abcde") {
t.Errorf("Want %d, but got %d", len("abcde"), buf.cursorPosition)
}
// Go to the beginning of the line
applyEmacsKeyBind(buf, ControlA)
if buf.cursorPosition != 0 {
t.Errorf("Want %d, but got %d", 0, buf.cursorPosition)
}
// Go to the end of the line
applyEmacsKeyBind(buf, ControlE)
if buf.cursorPosition != len("abcde") {
t.Errorf("Want %d, but got %d", len("abcde"), buf.cursorPosition)
}
}
func applyEmacsKeyBind(buf *Buffer, key Key) {
for i := range emacsKeyBindings {
kb := emacsKeyBindings[i]
if kb.Key == key {
kb.Fn(buf)
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_influxdata/go-prompt.git
git@gitee.com:mirrors_influxdata/go-prompt.git
mirrors_influxdata
go-prompt
go-prompt
master

搜索帮助