Make get_input clean-up after itself

This commit is contained in:
Matúš Púll 2025-05-28 16:22:48 +02:00
parent 7259c7ba7a
commit 68b1b176e6

View file

@ -46,6 +46,7 @@ string Editor::get_input(string prompt, F func) {
print_text(cur.r, prompt+": " + s); print_text(cur.r, prompt+": " + s);
ch = getch(); ch = getch();
} }
print_current_line();
return s; return s;
} }
// Taking user input - string // Taking user input - string
@ -191,14 +192,11 @@ bool Editor::take_action() {
break; break;
case 'f': case 'f':
last_find = get_string("to find"); last_find = get_string("to find");
print_current_line();
case 'n': case 'n':
{ {
auto result = find(last_find); auto result = find(last_find);
if(!result.first) { if(!result.first)
print_current_line();
break; break;
}
jump(result.second); jump(result.second);
} }
print_file(file_offset); print_file(file_offset);
@ -206,14 +204,11 @@ bool Editor::take_action() {
case 's': case 's':
last_find = get_string("to find"); last_find = get_string("to find");
last_replace = get_string("to replace"); last_replace = get_string("to replace");
print_current_line();
case 'r': case 'r':
{ {
auto result = find(last_find); auto result = find(last_find);
if(!result.first) { if(!result.first)
print_current_line();
break; break;
}
jump(result.second); jump(result.second);
replace(cur + file_offset, last_find.size(), last_replace); replace(cur + file_offset, last_find.size(), last_replace);
} }