Skip to content

Commit

Permalink
chore: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Sep 30, 2023
1 parent 822fbd6 commit 86a97c0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: wasm32-wasi

- name: Build
run: cargo build --release

- name: Format
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
28 changes: 11 additions & 17 deletions src/main.rs
Expand Up @@ -21,19 +21,20 @@ impl Default for State {
}

impl State {

fn filter(&self, tab: &&TabInfo) -> bool {
if self.ignore_case {
tab.name.to_lowercase() == self.filter.to_lowercase() || tab.name.to_lowercase().contains(&self.filter.to_lowercase())
tab.name.to_lowercase() == self.filter.to_lowercase()
|| tab
.name
.to_lowercase()
.contains(&self.filter.to_lowercase())
} else {
tab.name == self.filter || tab.name.contains(&self.filter)
}
}

fn viewable_tabs_iter(&self) -> impl Iterator<Item = &TabInfo> {
self.tabs
.iter()
.filter(|tab| self.filter(tab))
self.tabs.iter().filter(|tab| self.filter(tab))
}

fn viewable_tabs(&self) -> Vec<&TabInfo> {
Expand All @@ -51,10 +52,7 @@ impl State {
}

fn select_down(&mut self) {
let tabs = self
.tabs
.iter()
.filter(|tab| self.filter(tab));
let tabs = self.tabs.iter().filter(|tab| self.filter(tab));

let mut can_select = false;
let mut first = None;
Expand All @@ -77,11 +75,7 @@ impl State {
}

fn select_up(&mut self) {
let tabs = self
.tabs
.iter()
.filter(|tab| self.filter(tab))
.rev();
let tabs = self.tabs.iter().filter(|tab| self.filter(tab)).rev();

let mut can_select = false;
let mut last = None;
Expand All @@ -107,7 +101,7 @@ impl State {
register_plugin!(State);

impl ZellijPlugin for State {
fn load(&mut self, _configuration: BTreeMap<String, String>) {
fn load(&mut self, configuration: BTreeMap<String, String>) {
// we need the ReadApplicationState permission to receive the ModeUpdate and TabUpdate
// events
// we need the ChangeApplicationState permission to Change Zellij state (Panes, Tabs and UI)
Expand All @@ -116,9 +110,9 @@ impl ZellijPlugin for State {
PermissionType::ChangeApplicationState,
]);

self.ignore_case = match _configuration.get(&"ignore_case" as &str) {
self.ignore_case = match configuration.get("ignore_case" as &str) {
Some(value) => value.trim().parse().unwrap(),
None => true
None => true,
};

subscribe(&[EventType::TabUpdate, EventType::Key]);
Expand Down

0 comments on commit 86a97c0

Please sign in to comment.