Improved sudo handling in autocomplete
This commit is contained in:
		| @ -109,33 +109,36 @@ impl Search { | |||||||
|  |  | ||||||
|     fn discriminate_search_type(input: &String) -> SearchType { |     fn discriminate_search_type(input: &String) -> SearchType { | ||||||
|         let tamere = input.clone(); |         let tamere = input.clone(); | ||||||
|  |         let tamere2 = tamere.split("|") | ||||||
|  |             .collect::<Vec<&str>>(); | ||||||
|  |         let mut command = String::from(*tamere2.last().unwrap()); | ||||||
|  |  | ||||||
|         //Special cases |         //Special cases | ||||||
|         //./Means we want to execute something in place |         //./Means we want to execute something in place | ||||||
|         if input.starts_with("./") || input.starts_with(" ./") { |         if command.starts_with("./") || command.starts_with(" ./") { | ||||||
|             return SearchType::FileSearch; |             return SearchType::FileSearch; | ||||||
|         } |         } | ||||||
|         if input.starts_with("sudo") || input.starts_with("watch ") { |         if command.starts_with("watch ") { | ||||||
|             return SearchType::CmdSearch; |             return SearchType::CmdSearch; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         let mut a = tamere.split(" ").collect::<Vec<&str>>(); |         //sudo is not taken into account when autocompleting | ||||||
|  |         command = command.replace("sudo ", ""); | ||||||
|  |  | ||||||
|  |         let mut a = command.split(" ").collect::<Vec<&str>>(); | ||||||
|         let _y = String::from(a.pop().unwrap()); |         let _y = String::from(a.pop().unwrap()); | ||||||
|         let mut x = String::from(a.join(" ").trim()); |         let mut x = String::from(a.join(" ").trim()); | ||||||
|         if x.len() > 0 { |         if x.len() > 0 { | ||||||
|             x.push_str(" ") |             x.push_str(" ") | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|  |         let y = x.split(" ").collect::<Vec<&str>>(); | ||||||
|         if x.pop() == Some(' ') { |         if y.len() > 1 { | ||||||
|             if x.pop() == Some('|') { |             return SearchType::FileSearch; | ||||||
|                 return SearchType::CmdSearch; |  | ||||||
|             } else { |  | ||||||
|                 return SearchType::FileSearch; |  | ||||||
|             } |  | ||||||
|         } else { |         } else { | ||||||
|             return SearchType::CmdSearch; |             return SearchType::CmdSearch; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user