Ver código fonte

fix: allow deleting first character

Sam Jaffe 1 ano atrás
pai
commit
3627fac919
1 arquivos alterados com 3 adições e 3 exclusões
  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: