fix linting issues and ignore derive docs for tests

This commit is contained in:
alexpasmantier 2024-10-31 14:08:10 +01:00
parent 7045295e12
commit 40f466548b
6 changed files with 22 additions and 27 deletions

View File

@ -33,8 +33,10 @@
- [x] support for images is implemented but do we really want that in the core? - [x] support for images is implemented but do we really want that in the core?
it's quite heavy it's quite heavy
- [x] shrink entry names that are too long (from the middle) - [x] shrink entry names that are too long (from the middle)
- [ ] more syntaxes for the previewer https://www.sublimetext.com/docs/syntax.html#include-syntax
- [ ] more preview colorschemes
## feature ideas ## features
- [x] environment variables - [x] environment variables
- [x] aliases - [x] aliases

View File

@ -110,11 +110,7 @@ impl Channel {
); );
let injector = matcher.injector(); let injector = matcher.injector();
let load_handle = tokio::spawn(async move { let load_handle = tokio::spawn(async move {
let mut lines_in_mem = 0; for entry in entries.into_iter().take(MAX_LINES_IN_MEM) {
for entry in entries {
if lines_in_mem > MAX_LINES_IN_MEM {
break;
}
injector.push( injector.push(
CandidateLine::new( CandidateLine::new(
entry.display_name().into(), entry.display_name().into(),
@ -125,7 +121,6 @@ impl Channel {
cols[0] = c.line.clone().into(); cols[0] = c.line.clone().into();
}, },
); );
lines_in_mem += 1;
} }
}); });
@ -224,7 +219,7 @@ impl OnAir for Channel {
.matched_items( .matched_items(
offset offset
..(num_entries + offset) ..(num_entries + offset)
.min(snapshot.matched_item_count()), .min(snapshot.matched_item_count()),
) )
.map(move |item| { .map(move |item| {
snapshot.pattern().column_pattern(0).indices( snapshot.pattern().column_pattern(0).indices(
@ -243,11 +238,11 @@ impl OnAir for Channel {
display_path.clone() + &item.data.line_number.to_string(), display_path.clone() + &item.data.line_number.to_string(),
PreviewType::Files, PreviewType::Files,
) )
.with_display_name(display_path) .with_display_name(display_path)
.with_value(line) .with_value(line)
.with_value_match_ranges(indices.map(|i| (i, i + 1)).collect()) .with_value_match_ranges(indices.map(|i| (i, i + 1)).collect())
.with_icon(FileIcon::from(item.data.path.as_path())) .with_icon(FileIcon::from(item.data.path.as_path()))
.with_line_number(item.data.line_number) .with_line_number(item.data.line_number)
}) })
.collect() .collect()
} }
@ -369,7 +364,7 @@ fn try_inject_lines(
if (bytes_read == 0) if (bytes_read == 0)
|| is_not_text(&buffer).unwrap_or(false) || is_not_text(&buffer).unwrap_or(false)
|| proportion_of_printable_ascii_characters(&buffer) || proportion_of_printable_ascii_characters(&buffer)
< PRINTABLE_ASCII_THRESHOLD < PRINTABLE_ASCII_THRESHOLD
{ {
return None; return None;
} }

View File

@ -333,14 +333,11 @@ impl Television {
} }
} }
} }
Action::CopyEntryToClipboard => match self.mode { Action::CopyEntryToClipboard => if self.mode == Mode::Channel {
Mode::Channel => { if let Some(entry) = self.get_selected_entry(None) {
if let Some(entry) = self.get_selected_entry(None) { let mut ctx = ClipboardContext::new().unwrap();
let mut ctx = ClipboardContext::new().unwrap(); ctx.set_contents(entry.name).unwrap();
ctx.set_contents(entry.name).unwrap();
}
} }
_ => {}
}, },
Action::ToggleSendToChannel => match self.mode { Action::ToggleSendToChannel => match self.mode {
Mode::Channel | Mode::RemoteControl => { Mode::Channel | Mode::RemoteControl => {

View File

@ -30,6 +30,7 @@ pub struct Layout {
} }
impl Layout { impl Layout {
#[allow(clippy::too_many_arguments)]
pub fn new( pub fn new(
help_bar_left: Rect, help_bar_left: Rect,
help_bar_middle: Rect, help_bar_middle: Rect,

View File

@ -98,7 +98,7 @@ impl Television {
let preview_block = self.build_preview_paragraph( let preview_block = self.build_preview_paragraph(
preview_inner_block, preview_inner_block,
inner, inner,
&preview, preview,
selected_entry selected_entry
.line_number .line_number
.map(|l| u16::try_from(l).unwrap_or(0)), .map(|l| u16::try_from(l).unwrap_or(0)),
@ -174,9 +174,9 @@ impl Television {
self.preview_scroll.unwrap_or(0), self.preview_scroll.unwrap_or(0),
self.preview_pane_height, self.preview_pane_height,
) )
.block(preview_block) .block(preview_block)
.alignment(Alignment::Left) .alignment(Alignment::Left)
.scroll((self.preview_scroll.unwrap_or(0), 0)) .scroll((self.preview_scroll.unwrap_or(0), 0))
} }
// meta // meta
PreviewContent::Loading => self PreviewContent::Loading => self

View File

@ -4,7 +4,7 @@ use quote::quote;
/// This macro generates a `CliChannel` enum and the necessary glue code /// This macro generates a `CliChannel` enum and the necessary glue code
/// to convert into a `TelevisionChannel` member: /// to convert into a `TelevisionChannel` member:
/// ///
/// ```rust /// ```ignore
/// use crate::channels::{TelevisionChannel, OnAir}; /// use crate::channels::{TelevisionChannel, OnAir};
/// use television_derive::ToCliChannel; /// use television_derive::ToCliChannel;
/// use crate::channels::{files, text}; /// use crate::channels::{files, text};
@ -122,7 +122,7 @@ fn impl_cli_channel(ast: &syn::DeriveInput) -> TokenStream {
/// and forwards the method calls to the corresponding channel variants. /// and forwards the method calls to the corresponding channel variants.
/// ///
/// Example: /// Example:
/// ```rust /// ```ignore
/// use television_derive::Broadcast; /// use television_derive::Broadcast;
/// use crate::channels::{TelevisionChannel, OnAir}; /// use crate::channels::{TelevisionChannel, OnAir};
/// use crate::channels::{files, text}; /// use crate::channels::{files, text};