浏览代码

fix: allow deleting first character

Sam Jaffe 1 年之前
父节点
当前提交
3627fac919
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/cli.cxx

+ 3 - 3
src/cli.cxx

@@ -46,11 +46,11 @@ void Cli::loop(std::function<void(curses::Window &, std::string)> on_enter) {
     case KEY_BACKSPACE:
     case KEY_DC:
     case 127:
-      if (horizontal_offset_ + 1 < get().size()) {
+      if (horizontal_offset_ < get().size()) {
         get().erase(get().end() - horizontal_offset_ - 1);
+        window_.move(Offset{-1, 0});
+        window_.delch();
       }
-      window_.move(Offset{-1, 0});
-      window_.delch();
       break;
     case 10:
     case KEY_ENTER: