fix(misc): fix clippy warnings (#1342)
* fix(misc): fix clippy warnings * fix(misc): fix clippy warnings * fix(misc): fix clippy warnings * fix(misc): fix clippy warnings * fix(misc): fix clippy warnings
This commit is contained in:
parent
ee14983f7c
commit
5256e3e79f
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -16,6 +16,7 @@ env:
|
|||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest, ubuntu-latest]
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ impl ErrorRecord {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ErrorLevel {
|
||||
Error,
|
||||
Warning,
|
||||
|
|
|
@ -386,7 +386,7 @@ impl LegacyConfig {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
|
||||
pub enum BackendType {
|
||||
Inject,
|
||||
Clipboard,
|
||||
|
@ -740,7 +740,7 @@ impl LegacyConfigSet {
|
|||
}
|
||||
|
||||
// Error handling
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[allow(dead_code)]
|
||||
pub enum ConfigLoadError {
|
||||
FileNotFound,
|
||||
|
|
|
@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
|
||||
pub enum KeyModifier {
|
||||
CTRL,
|
||||
SHIFT,
|
||||
|
|
|
@ -119,7 +119,7 @@ pub struct YAMLMatch {
|
|||
pub search_terms: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub struct YAMLVariable {
|
||||
pub name: String,
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ pub trait MatchStore: Send {
|
|||
fn loaded_paths(&self) -> Vec<String>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MatchSet<'a> {
|
||||
pub matches: Vec<&'a Match>,
|
||||
pub global_vars: Vec<&'a Variable>,
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#[cfg(test)]
|
||||
use enum_as_inner::EnumAsInner;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(EnumAsInner))]
|
||||
pub enum InputEvent {
|
||||
Mouse(MouseEvent),
|
||||
|
@ -32,7 +32,7 @@ pub enum InputEvent {
|
|||
AllModifiersReleased,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum MouseButton {
|
||||
Left,
|
||||
Right,
|
||||
|
@ -44,25 +44,25 @@ pub enum MouseButton {
|
|||
Button5,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct MouseEvent {
|
||||
pub button: MouseButton,
|
||||
pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Status {
|
||||
Pressed,
|
||||
Released,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Variant {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct KeyboardEvent {
|
||||
pub key: Key,
|
||||
pub value: Option<String>,
|
||||
|
@ -72,7 +72,7 @@ pub struct KeyboardEvent {
|
|||
}
|
||||
|
||||
// A subset of the Web's key values: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Key {
|
||||
// Modifiers
|
||||
Alt,
|
||||
|
@ -141,7 +141,7 @@ pub enum Key {
|
|||
Other(i32),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct HotKeyEvent {
|
||||
pub hotkey_id: i32,
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ lazy_static! {
|
|||
static ref RAW_PARSER: Regex = Regex::new(r"^RAW\((\d+)\)$").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub enum ShortcutKey {
|
||||
Alt,
|
||||
Control,
|
||||
|
|
|
@ -32,7 +32,7 @@ static MODIFIERS: &[ShortcutKey; 4] = &[
|
|||
ShortcutKey::Meta,
|
||||
];
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub struct HotKey {
|
||||
pub id: i32,
|
||||
pub key: ShortcutKey,
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
use super::input::Key;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TriggerCompensationEvent {
|
||||
pub trigger: String,
|
||||
pub left_separator: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CursorHintCompensationEvent {
|
||||
pub cursor_hint_back_count: usize,
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub struct HtmlInjectRequest {
|
|||
pub html: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub enum TextInjectMode {
|
||||
Keys,
|
||||
Clipboard,
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MatchExecRequestEvent {
|
||||
pub trigger: Option<String>,
|
||||
pub args: HashMap<String, String>,
|
||||
|
|
|
@ -17,19 +17,19 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub enum Status {
|
||||
Pressed,
|
||||
Released,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub enum Variant {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub struct KeyboardEvent {
|
||||
pub key: Key,
|
||||
pub value: Option<String>,
|
||||
|
@ -37,7 +37,7 @@ pub struct KeyboardEvent {
|
|||
pub variant: Option<Variant>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum MouseButton {
|
||||
Left,
|
||||
Right,
|
||||
|
@ -49,13 +49,13 @@ pub enum MouseButton {
|
|||
Button5,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MouseEvent {
|
||||
pub button: MouseButton,
|
||||
pub status: Status,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Key {
|
||||
// Modifiers
|
||||
Alt,
|
||||
|
@ -124,12 +124,12 @@ pub enum Key {
|
|||
Other(i32),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ContextMenuClickedEvent {
|
||||
pub context_item_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct HotKeyEvent {
|
||||
pub hotkey_id: i32,
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MatchesDetectedEvent {
|
||||
pub matches: Vec<DetectedMatch>,
|
||||
pub is_search: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Eq)]
|
||||
pub struct DetectedMatch {
|
||||
pub id: i32,
|
||||
pub trigger: Option<String>,
|
||||
|
@ -34,17 +34,17 @@ pub struct DetectedMatch {
|
|||
pub args: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MatchSelectedEvent {
|
||||
pub chosen: DetectedMatch,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CauseCompensatedMatchEvent {
|
||||
pub m: DetectedMatch,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct RenderingRequestedEvent {
|
||||
pub match_id: i32,
|
||||
pub trigger: Option<String>,
|
||||
|
@ -54,38 +54,38 @@ pub struct RenderingRequestedEvent {
|
|||
pub format: TextFormat,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum TextFormat {
|
||||
Plain,
|
||||
Markdown,
|
||||
Html,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ImageRequestedEvent {
|
||||
pub match_id: i32,
|
||||
pub image_path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ImageResolvedEvent {
|
||||
pub image_path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct RenderedEvent {
|
||||
pub match_id: i32,
|
||||
pub body: String,
|
||||
pub format: TextFormat,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct DiscardPreviousEvent {
|
||||
// All Events with a source_id smaller than this one will be discarded
|
||||
pub minimum_source_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct DiscardBetweenEvent {
|
||||
// All Events with a source_id between start_id (included) and end_id (excluded)
|
||||
// will be discarded
|
||||
|
@ -93,13 +93,13 @@ pub struct DiscardBetweenEvent {
|
|||
pub end_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SecureInputEnabledEvent {
|
||||
pub app_name: String,
|
||||
pub app_path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct UndoEvent {
|
||||
pub match_id: i32,
|
||||
pub trigger: String,
|
||||
|
|
|
@ -29,7 +29,7 @@ pub enum MenuItem {
|
|||
Separator,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SimpleMenuItem {
|
||||
pub id: u32,
|
||||
pub label: String,
|
||||
|
@ -41,19 +41,19 @@ pub struct SubMenuItem {
|
|||
pub items: Vec<MenuItem>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct IconStatusChangeEvent {
|
||||
pub status: IconStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum IconStatus {
|
||||
Enabled,
|
||||
Disabled,
|
||||
SecureInputDisabled,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ShowTextEvent {
|
||||
pub title: String,
|
||||
pub text: String,
|
||||
|
|
|
@ -44,7 +44,7 @@ pub enum MatcherEvent {
|
|||
VirtualSeparator,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MatchResult {
|
||||
pub id: i32,
|
||||
pub trigger: String,
|
||||
|
@ -104,7 +104,7 @@ impl<'a, State> Middleware for MatcherMiddleware<'a, State> {
|
|||
if is_event_of_interest(&event.etype) {
|
||||
let mut matcher_states = self.matcher_states.borrow_mut();
|
||||
let prev_states = if !matcher_states.is_empty() {
|
||||
matcher_states.get(matcher_states.len() - 1)
|
||||
matcher_states.back()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ pub const KeyPress: c_int = 2;
|
|||
#[allow(non_upper_case_globals)]
|
||||
pub const KeyRelease: c_int = 3;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct XKeyEvent {
|
||||
pub type_: c_int,
|
||||
|
@ -40,7 +40,7 @@ pub struct XKeyEvent {
|
|||
pub same_screen: Bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub struct XModifierKeymap {
|
||||
pub max_keypermod: c_int,
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Event {
|
||||
Key { key: Key, chars: Option<String> },
|
||||
VirtualSeparator,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Key {
|
||||
// Modifiers
|
||||
Alt,
|
||||
|
|
|
@ -26,7 +26,7 @@ pub mod regex;
|
|||
pub mod rolling;
|
||||
mod util;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MatchResult<Id> {
|
||||
pub id: Id,
|
||||
pub trigger: String,
|
||||
|
|
|
@ -185,7 +185,7 @@ impl<Id: Clone> RollingMatcher<Id> {
|
|||
// in the state.
|
||||
if !has_previous_state {
|
||||
if let Some(MatcherTreeRef::Node(node)) = node.word_separators.as_ref() {
|
||||
refs.extend(self.find_refs(&*node, event, true));
|
||||
refs.extend(self.find_refs(node, event, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ pub mod matcher;
|
|||
mod tree;
|
||||
mod util;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum RollingItem {
|
||||
WordSeparator,
|
||||
Key(Key),
|
||||
|
@ -31,7 +31,7 @@ pub enum RollingItem {
|
|||
CharInsensitive(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct RollingMatch<Id> {
|
||||
pub id: Id,
|
||||
pub items: Vec<RollingItem>,
|
||||
|
|
|
@ -90,7 +90,7 @@ fn build_native() {
|
|||
)
|
||||
.args(&[
|
||||
"/k",
|
||||
&vcvars_path.to_string_lossy().to_string(),
|
||||
&vcvars_path.to_string_lossy(),
|
||||
"&",
|
||||
"nmake",
|
||||
"/f",
|
||||
|
@ -320,7 +320,7 @@ fn convert_fat_libraries_to_arm(lib_dir: &Path) {
|
|||
|
||||
// Make sure it's a fat library
|
||||
let lipo_output = std::process::Command::new("lipo")
|
||||
.args(&["-detailed_info", &path.to_string_lossy().to_string()])
|
||||
.args(&["-detailed_info", &path.to_string_lossy()])
|
||||
.output()
|
||||
.expect("unable to check if library is fat");
|
||||
let lipo_output = String::from_utf8_lossy(&lipo_output.stdout);
|
||||
|
@ -339,9 +339,9 @@ fn convert_fat_libraries_to_arm(lib_dir: &Path) {
|
|||
.args(&[
|
||||
"-thin",
|
||||
"arm64",
|
||||
&path.to_string_lossy().to_string(),
|
||||
&path.to_string_lossy(),
|
||||
"-output",
|
||||
&path.to_string_lossy().to_string(),
|
||||
&path.to_string_lossy(),
|
||||
])
|
||||
.output()
|
||||
.expect("unable to extract arm64 slice from library");
|
||||
|
|
|
@ -25,7 +25,7 @@ lazy_static! {
|
|||
static ref FIELD_REGEX: Regex = Regex::new(r"\{\{(.*?)\}\}|\[\[(.*?)\]\]").unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Token {
|
||||
Text(String), // Text
|
||||
Field(String), // id: String
|
||||
|
|
|
@ -21,11 +21,10 @@ use std::collections::HashSet;
|
|||
|
||||
use crate::sys::search::types::SearchItem;
|
||||
|
||||
pub fn get_algorithm(
|
||||
name: &str,
|
||||
use_command_filter: bool,
|
||||
) -> Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>> {
|
||||
let search_algorithm: Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>> = match name {
|
||||
type FilterCallback = dyn Fn(&str, &[SearchItem]) -> Vec<usize>;
|
||||
|
||||
pub fn get_algorithm(name: &str, use_command_filter: bool) -> Box<FilterCallback> {
|
||||
let search_algorithm: Box<FilterCallback> = match name {
|
||||
"exact" => Box::new(exact_match),
|
||||
"iexact" => Box::new(case_insensitive_exact_match),
|
||||
"ikey" => Box::new(case_insensitive_keyword),
|
||||
|
@ -100,9 +99,7 @@ fn case_insensitive_keyword(query: &str, items: &[SearchItem]) -> Vec<usize> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn command_filter(
|
||||
search_algorithm: Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>>,
|
||||
) -> Box<dyn Fn(&str, &[SearchItem]) -> Vec<usize>> {
|
||||
fn command_filter(search_algorithm: Box<FilterCallback>) -> Box<FilterCallback> {
|
||||
Box::new(move |query, items| {
|
||||
let (valid_ids, trimmed_query) = if query.starts_with('>') {
|
||||
(
|
||||
|
|
|
@ -147,16 +147,15 @@ mod interop {
|
|||
}
|
||||
}
|
||||
|
||||
type SearchAlgorithmCallback = dyn Fn(&str, &[types::SearchItem]) -> Vec<usize>;
|
||||
|
||||
struct SearchData {
|
||||
owned_search: interop::OwnedSearch,
|
||||
items: Vec<types::SearchItem>,
|
||||
algorithm: Box<dyn Fn(&str, &[types::SearchItem]) -> Vec<usize>>,
|
||||
algorithm: Box<SearchAlgorithmCallback>,
|
||||
}
|
||||
|
||||
pub fn show(
|
||||
search: types::Search,
|
||||
algorithm: Box<dyn Fn(&str, &[types::SearchItem]) -> Vec<usize>>,
|
||||
) -> Option<String> {
|
||||
pub fn show(search: types::Search, algorithm: Box<SearchAlgorithmCallback>) -> Option<String> {
|
||||
use super::interop::*;
|
||||
|
||||
let owned_search: interop::OwnedSearch = (&search).into();
|
||||
|
|
|
@ -44,7 +44,9 @@ pub enum ErrorLevel {
|
|||
Warning,
|
||||
}
|
||||
|
||||
type OpenFileCallback = dyn Fn(&Path) + Send;
|
||||
|
||||
pub struct TroubleshootingHandlers {
|
||||
pub dont_show_again_changed: Option<Box<dyn Fn(bool) + Send>>,
|
||||
pub open_file: Option<Box<dyn Fn(&Path) + Send>>,
|
||||
pub open_file: Option<Box<OpenFileCallback>>,
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ mod util;
|
|||
|
||||
pub const PACKAGE_SOURCE_FILE: &str = "_pkgsource.yml";
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ArchivedPackage {
|
||||
// Metadata
|
||||
pub manifest: Manifest,
|
||||
|
@ -39,12 +39,12 @@ pub struct ArchivedPackage {
|
|||
pub source: PackageSource,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct LegacyPackage {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum StoredPackage {
|
||||
Legacy(LegacyPackage),
|
||||
Modern(ArchivedPackage),
|
||||
|
@ -67,7 +67,7 @@ pub struct SaveOptions {
|
|||
pub overwrite_existing: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum PackageSource {
|
||||
Hub,
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::path::Path;
|
|||
use anyhow::{Context, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Eq)]
|
||||
pub struct Manifest {
|
||||
pub name: String,
|
||||
pub title: String,
|
||||
|
|
|
@ -23,7 +23,7 @@ use anyhow::{anyhow, bail, Context, Result};
|
|||
|
||||
use crate::manifest::Manifest;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ResolvedPackage {
|
||||
pub manifest: Manifest,
|
||||
pub base_dir: PathBuf,
|
||||
|
|
|
@ -82,7 +82,7 @@ fn extract_zip(data: Vec<u8>, dest_dir: &Path) -> Result<()> {
|
|||
None => continue,
|
||||
};
|
||||
|
||||
if (&*file.name()).ends_with('/') {
|
||||
if file.name().ends_with('/') {
|
||||
std::fs::create_dir_all(&outpath)?;
|
||||
} else {
|
||||
if let Some(p) = outpath.parent() {
|
||||
|
|
|
@ -28,7 +28,7 @@ lazy_static! {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct GitHubParts {
|
||||
author: String,
|
||||
name: String,
|
||||
|
|
|
@ -28,7 +28,7 @@ lazy_static! {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct GitLabParts {
|
||||
author: String,
|
||||
name: String,
|
||||
|
|
|
@ -66,16 +66,13 @@ impl Extension for ScriptExtension {
|
|||
// Also replace %CONFIG% and %PACKAGES% path. See issue #380
|
||||
args.iter_mut().for_each(|arg| {
|
||||
if arg.contains("%HOME%") {
|
||||
*arg = arg.replace("%HOME%", &self.home_path.to_string_lossy().to_string());
|
||||
*arg = arg.replace("%HOME%", &self.home_path.to_string_lossy());
|
||||
}
|
||||
if arg.contains("%CONFIG%") {
|
||||
*arg = arg.replace("%CONFIG%", &self.config_path.to_string_lossy().to_string());
|
||||
*arg = arg.replace("%CONFIG%", &self.config_path.to_string_lossy());
|
||||
}
|
||||
if arg.contains("%PACKAGES%") {
|
||||
*arg = arg.replace(
|
||||
"%PACKAGES%",
|
||||
&self.packages_path.to_string_lossy().to_string(),
|
||||
);
|
||||
*arg = arg.replace("%PACKAGES%", &self.packages_path.to_string_lossy());
|
||||
}
|
||||
|
||||
// On Windows, correct paths separators
|
||||
|
|
|
@ -48,7 +48,7 @@ pub struct Context<'a> {
|
|||
pub templates: Vec<&'a Template>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct RenderOptions {
|
||||
pub casing_style: CasingStyle,
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ impl Default for RenderOptions {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum CasingStyle {
|
||||
None,
|
||||
Capitalize,
|
||||
|
@ -123,7 +123,7 @@ pub trait Extension {
|
|||
|
||||
pub type Scope<'a> = HashMap<&'a str, ExtensionOutput>;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ExtensionOutput {
|
||||
Single(String),
|
||||
Multiple(HashMap<String, String>),
|
||||
|
|
|
@ -78,7 +78,7 @@ pub(crate) fn render_variables(body: &str, scope: &Scope) -> Result<String> {
|
|||
ExtensionOutput::Multiple(results) => match var_subname {
|
||||
Some(var_subname) => {
|
||||
let var_subname = var_subname.as_str();
|
||||
results.get(var_subname).map_or("", |value| &*value)
|
||||
results.get(var_subname).map_or("", |value| value)
|
||||
}
|
||||
None => {
|
||||
error!(
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq)]
|
||||
pub enum UIEvent {
|
||||
TrayIconClick,
|
||||
ContextMenuClick(u32),
|
||||
|
|
|
@ -67,7 +67,7 @@ impl Default for CliModule {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum LogMode {
|
||||
Read,
|
||||
AppendOnly,
|
||||
|
|
|
@ -42,10 +42,8 @@ pub fn register() -> Result<()> {
|
|||
info_println!("creating service file in {:?}", service_file);
|
||||
let espanso_path = get_binary_path().expect("unable to get espanso executable path");
|
||||
|
||||
let service_content = String::from(LINUX_SERVICE_CONTENT).replace(
|
||||
"{{{espanso_path}}}",
|
||||
&espanso_path.to_string_lossy().to_string(),
|
||||
);
|
||||
let service_content = String::from(LINUX_SERVICE_CONTENT)
|
||||
.replace("{{{espanso_path}}}", &espanso_path.to_string_lossy());
|
||||
|
||||
std::fs::write(service_file, service_content)?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user