summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2023-05-15 21:10:02 +1000
committerMaxime Coste <mawww@kakoune.org>2023-05-21 16:20:51 +1000
commitcfa658b899b44a8a0f4c7f3dd9811ae0d44ddd3a (patch)
tree80613249d2988b09ebc7eaa85a91f811959931f3 /src/main.cc
parente140df8f0857125f40f9338450f73ff1ac50664d (diff)
Add <c-g> to cancel current operation
The current implementation only does this during regex operations, but should be extensible to other operations that might take a long time by regularly calling EventManager::handle_urgent_events().
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main.cc b/src/main.cc
index 609fea47..e49a1d0d 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -894,12 +894,17 @@ int run_server(StringView session, StringView server_init,
// Loop so that eventual inputs happening during the processing are handled as
// well, avoiding unneeded redraws.
bool allow_blocking = not client_manager.has_pending_inputs();
- while (event_manager.handle_next_events(EventMode::Normal, nullptr, allow_blocking))
+ try
{
- if (client_manager.process_pending_inputs())
- break;
- allow_blocking = false;
+ while (event_manager.handle_next_events(EventMode::Normal, nullptr, allow_blocking))
+ {
+ if (client_manager.process_pending_inputs())
+ break;
+ allow_blocking = false;
+ }
}
+ catch (const cancel&) {}
+
client_manager.process_pending_inputs();
client_manager.clear_client_trash();