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