feat: optimize naming
This commit is contained in:
22
src/msg.rs
22
src/msg.rs
@@ -203,33 +203,25 @@ pub fn get_room_message_type(first_part: &str) -> XResult<RoomMessageType> {
|
||||
fn parse_message_parts(msg: &str) -> Vec<String> {
|
||||
let mut msg_parts = vec![];
|
||||
let mut in_quote = false;
|
||||
let mut is_back_slash = false;
|
||||
let mut is_last_char_back_slash = false;
|
||||
let mut last_part = vec![];
|
||||
for c in msg.chars().skip(1) {
|
||||
if is_back_slash {
|
||||
if is_last_char_back_slash {
|
||||
last_part.push(c);
|
||||
is_back_slash = false;
|
||||
is_last_char_back_slash = false;
|
||||
continue;
|
||||
}
|
||||
match c {
|
||||
' ' if in_quote => {
|
||||
last_part.push(c);
|
||||
}
|
||||
' ' if in_quote => { last_part.push(c); }
|
||||
' ' => {
|
||||
if !last_part.is_empty() {
|
||||
msg_parts.push(last_part.iter().collect::<String>());
|
||||
last_part.clear();
|
||||
}
|
||||
}
|
||||
'\\' => {
|
||||
is_back_slash = true;
|
||||
}
|
||||
'\'' => {
|
||||
in_quote = !in_quote;
|
||||
}
|
||||
_ => {
|
||||
last_part.push(c);
|
||||
}
|
||||
'\\' => { is_last_char_back_slash = true; }
|
||||
'\'' => { in_quote = !in_quote; }
|
||||
_ => { last_part.push(c); }
|
||||
}
|
||||
}
|
||||
if !last_part.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user