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> {
|
fn parse_message_parts(msg: &str) -> Vec<String> {
|
||||||
let mut msg_parts = vec![];
|
let mut msg_parts = vec![];
|
||||||
let mut in_quote = false;
|
let mut in_quote = false;
|
||||||
let mut is_back_slash = false;
|
let mut is_last_char_back_slash = false;
|
||||||
let mut last_part = vec![];
|
let mut last_part = vec![];
|
||||||
for c in msg.chars().skip(1) {
|
for c in msg.chars().skip(1) {
|
||||||
if is_back_slash {
|
if is_last_char_back_slash {
|
||||||
last_part.push(c);
|
last_part.push(c);
|
||||||
is_back_slash = false;
|
is_last_char_back_slash = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
match c {
|
match c {
|
||||||
' ' if in_quote => {
|
' ' if in_quote => { last_part.push(c); }
|
||||||
last_part.push(c);
|
|
||||||
}
|
|
||||||
' ' => {
|
' ' => {
|
||||||
if !last_part.is_empty() {
|
if !last_part.is_empty() {
|
||||||
msg_parts.push(last_part.iter().collect::<String>());
|
msg_parts.push(last_part.iter().collect::<String>());
|
||||||
last_part.clear();
|
last_part.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'\\' => {
|
'\\' => { is_last_char_back_slash = true; }
|
||||||
is_back_slash = true;
|
'\'' => { in_quote = !in_quote; }
|
||||||
}
|
_ => { last_part.push(c); }
|
||||||
'\'' => {
|
|
||||||
in_quote = !in_quote;
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
last_part.push(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !last_part.is_empty() {
|
if !last_part.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user