|
|
@@ -1,5 +1,6 @@
|
|
|
#include "lumacs/keybinding.hpp"
|
|
|
#include "lumacs/command_system.hpp" // Include for CommandSystem
|
|
|
+#include "lumacs/editor_core.hpp" // Needed for EditorCore definition
|
|
|
#include <sstream>
|
|
|
#include <algorithm>
|
|
|
#include <cctype>
|
|
|
@@ -11,6 +12,7 @@ namespace lumacs {
|
|
|
// ============================================================================
|
|
|
|
|
|
namespace {
|
|
|
+// ... (keep anonymous namespace as is) ...
|
|
|
// Helper to convert string to BaseKey
|
|
|
BaseKey string_to_base_key(const std::string& s) {
|
|
|
if (s.length() == 1) {
|
|
|
@@ -359,12 +361,27 @@ KeyProcessingResult KeyBindingManager::process_key(const Key& key) {
|
|
|
if (node && node->binding.has_value()) {
|
|
|
// Found exact match
|
|
|
KeyBinding bound_command = node->binding.value();
|
|
|
+
|
|
|
+ // Capture the raw key string of the full sequence before clearing
|
|
|
+ std::string sequence_str = current_sequence_.to_string();
|
|
|
clear_partial_sequence();
|
|
|
|
|
|
try {
|
|
|
// Execute the command via the CommandSystem
|
|
|
if (command_system_) {
|
|
|
+ // --- Macro Recording Logic ---
|
|
|
+ bool was_recording = command_system_->core().is_recording_macro();
|
|
|
+
|
|
|
CommandResult cmd_result = command_system_->execute(bound_command.command_name, {}); // No args for now
|
|
|
+
|
|
|
+ bool is_recording = command_system_->core().is_recording_macro();
|
|
|
+
|
|
|
+ // Only record if we were recording BEFORE execution and are STILL recording AFTER execution.
|
|
|
+ if (was_recording && is_recording) {
|
|
|
+ command_system_->core().record_key_sequence(sequence_str);
|
|
|
+ }
|
|
|
+ // -----------------------------
|
|
|
+
|
|
|
return KeyProcessingResult(cmd_result.status == CommandStatus::Success ? KeyResult::Executed : KeyResult::Failed, cmd_result);
|
|
|
}
|
|
|
return KeyProcessingResult(KeyResult::Failed, CommandResult{CommandStatus::Failure, "No CommandSystem available"});
|