fix: message bug and context menu bugs

This commit is contained in:
Evan Carroll 2026-01-18 22:43:30 -06:00
parent 15cc1f708f
commit 84cb4e5e78
3 changed files with 76 additions and 19 deletions

View file

@ -162,25 +162,24 @@ pub fn ChatInput(
return;
};
// Pre-fill with /whisper command
let placeholder = "your message here";
let whisper_text = format!("/whisper {} {}", target_name, placeholder);
// Pre-fill with /whisper command prefix only (no placeholder text)
// User types their message after the space
// parse_whisper_command already rejects empty messages
let whisper_prefix = format!("/whisper {} ", target_name);
if let Some(input) = input_ref.get() {
// Set the message
set_message.set(whisper_text.clone());
set_message.set(whisper_prefix.clone());
// Don't show hint - user already knows they're whispering
set_command_mode.set(CommandMode::None);
// Update input value
input.set_value(&whisper_text);
input.set_value(&whisper_prefix);
// Focus the input
// Focus the input and position cursor at end
let _ = input.focus();
// Select the placeholder text so it gets replaced when typing
let prefix_len = format!("/whisper {} ", target_name).len() as u32;
let total_len = whisper_text.len() as u32;
let _ = input.set_selection_range(prefix_len, total_len);
let len = whisper_prefix.len() as u32;
let _ = input.set_selection_range(len, len);
}
});
}
@ -230,8 +229,24 @@ pub fn ChatInput(
let cmd = value[1..].to_lowercase();
// Show hint for slash commands (don't execute until Enter)
// Match: /s[etting], /i[nventory], /w[hisper], or their full forms with args
if cmd.is_empty()
// Match: /s[etting], /i[nventory], /w[hisper]
// But NOT when whisper command is complete (has name + space for message)
let is_complete_whisper = {
// Check if it's "/w name " or "/whisper name " (name followed by space)
let rest = cmd.strip_prefix("whisper ").or_else(|| cmd.strip_prefix("w "));
if let Some(after_cmd) = rest {
// If there's content after the command and it contains a space,
// user has typed "name " and is now typing the message
after_cmd.contains(' ')
} else {
false
}
};
if is_complete_whisper {
// User is typing the message part, no hint needed
set_command_mode.set(CommandMode::None);
} else if cmd.is_empty()
|| "setting".starts_with(&cmd)
|| "inventory".starts_with(&cmd)
|| "whisper".starts_with(&cmd)