Commit d1bdb378c1

d1bdb378c12a40b1abf008bb956b9346ede7d6d6

parent: 91a945f7f1

Unregistered key

vaw <git@nlih.de> · 2026-09-04 01:07 UTC
committer: <noreply@github.com>

Add ignorecase setting (#669)

Co-authored-by: Axel <code@daguva.com>

Layout: unified · split

config.example.toml +1
@@ -10,6 +10,7 @@ default_markup = "html"
1010default_room = "#iamb-users:0x.badd.cafe"
1111default_split = "vertical"
1212external_edit_file_suffix = ".md"
13ignorecase = false
1314log_level = "warn"
1415members_split = "vertical"
1516message_shortcode_display = false
docs/iamb.5 +2
@@ -164,6 +164,8 @@ Suffix to append to temporary file names when using the :editor command. Default
164164Subsection for configuring image previews. See
165165.Sx "IMAGE PREVIEWS"
166166for more details.
167.It Sy ignorecase
168Defines whether searches ignore case. Defaults to false.
167169.It Sy log_level
168170Specifies the lowest log level that should be shown.
169171Possible values are:
src/config.rs +4
@@ -815,6 +815,7 @@ pub struct TerminalValues {
815815pub struct TunableValues {
816816 pub encryption: EncryptionValues,
817817 pub default_markup: MarkupFormat,
818 pub ignorecase: bool,
818819 pub log_level: String,
819820 pub max_log_files: usize,
820821 pub message_shortcode_display: bool,
@@ -869,6 +870,7 @@ pub struct Tunables {
869870 pub users: Option<UserOverrides>,
870871
871872 pub default_markup: Option<MarkupFormat>,
873 pub ignorecase: Option<bool>,
872874 pub log_level: Option<String>,
873875 pub max_log_files: Option<usize>,
874876 pub message_shortcode_display: Option<bool>,
@@ -912,6 +914,7 @@ impl Tunables {
912914 proxy: self.proxy.or(other.proxy),
913915
914916 default_markup: self.default_markup.or(other.default_markup),
917 ignorecase: self.ignorecase.or(other.ignorecase),
915918 log_level: self.log_level.or(other.log_level),
916919 max_log_files: self.max_log_files.or(other.max_log_files),
917920 message_shortcode_display: self
@@ -958,6 +961,7 @@ impl Tunables {
958961
959962 default_markup: self.default_markup.unwrap_or_default(),
960963 log_level: self.log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL.to_owned()),
964 ignorecase: self.ignorecase.unwrap_or(false),
961965 max_log_files: self.max_log_files.unwrap_or(7),
962966 message_shortcode_display: self.message_shortcode_display.unwrap_or(false),
963967 normal_after_send: self.normal_after_send.unwrap_or(false),
src/tests.rs +1
@@ -167,6 +167,7 @@ pub fn mock_dirs() -> DirectoryValues {
167167pub fn mock_tunables() -> TunableValues {
168168 TunableValues {
169169 default_markup: Default::default(),
170 ignorecase: false,
170171 default_room: None,
171172 encryption: Encryption::default().values(),
172173 log_level: "warn".into(),
src/util.rs +19
@@ -1,6 +1,7 @@
11//! # Utility functions
22use std::borrow::Cow;
33
4use regex::{Regex, RegexBuilder};
45use unicode_segmentation::UnicodeSegmentation;
56use unicode_width::UnicodeWidthStr;
67
@@ -182,10 +183,28 @@ pub fn replace_emojis_in_line(line: &mut Line) {
182183 }
183184}
184185
186/// Compile a search pattern, optionally ignoring case.
187pub fn compile_search(pattern: &str, case_insensitive: bool) -> Result<Regex, regex::Error> {
188 RegexBuilder::new(pattern).case_insensitive(case_insensitive).build()
189}
190
185191#[cfg(test)]
186192pub mod tests {
187193 use super::*;
188194
195 #[test]
196 fn test_compile_search_case_insensitive() {
197 let re = compile_search("chicken", true).unwrap();
198 assert!(re.is_match("CHICKEN"));
199 assert!(re.is_match("Chicken"));
200 assert!(re.is_match("chicken"));
201
202 let re = compile_search("chicken", false).unwrap();
203 assert!(!re.is_match("CHICKEN"));
204 assert!(!re.is_match("Chicken"));
205 assert!(re.is_match("chicken"));
206 }
207
189208 #[test]
190209 fn test_wrapped_lines_ascii() {
191210 let s = "hello world!\nabcdefghijklmnopqrstuvwxyz\ngoodbye";
src/windows/mod.rs +9
@@ -584,6 +584,7 @@ impl WindowOps<IambInfo> for IambWindow {
584584 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
585585
586586 state.set(items);
587 state.set_ignorecase(store.application.settings.tunables.ignorecase);
587588
588589 List::new(store)
589590 .empty_message("No direct messages yet!")
@@ -608,6 +609,8 @@ impl WindowOps<IambInfo> for IambWindow {
608609 *last_fetch = Some(Instant::now());
609610 }
610611
612 state.set_ignorecase(store.application.settings.tunables.ignorecase);
613
611614 List::new(store)
612615 .empty_message("No users here yet!")
613616 .empty_alignment(Alignment::Center)
@@ -628,6 +631,7 @@ impl WindowOps<IambInfo> for IambWindow {
628631 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
629632
630633 state.set(items);
634 state.set_ignorecase(store.application.settings.tunables.ignorecase);
631635
632636 List::new(store)
633637 .empty_message("You haven't joined any rooms yet")
@@ -660,6 +664,7 @@ impl WindowOps<IambInfo> for IambWindow {
660664 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
661665
662666 state.set(items);
667 state.set_ignorecase(store.application.settings.tunables.ignorecase);
663668
664669 List::new(store)
665670 .empty_message("You do not have rooms or dms yet")
@@ -694,6 +699,7 @@ impl WindowOps<IambInfo> for IambWindow {
694699 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
695700
696701 state.set(items);
702 state.set_ignorecase(store.application.settings.tunables.ignorecase);
697703
698704 List::new(store)
699705 .empty_message("You do not have any unreads yet")
@@ -728,6 +734,7 @@ impl WindowOps<IambInfo> for IambWindow {
728734 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
729735
730736 state.set(items);
737 state.set_ignorecase(store.application.settings.tunables.ignorecase);
731738
732739 List::new(store)
733740 .empty_message("You do not have any unread mentions yet")
@@ -749,6 +756,7 @@ impl WindowOps<IambInfo> for IambWindow {
749756 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
750757
751758 state.set(items);
759 state.set_ignorecase(store.application.settings.tunables.ignorecase);
752760
753761 List::new(store)
754762 .empty_message("You haven't joined any spaces yet")
@@ -764,6 +772,7 @@ impl WindowOps<IambInfo> for IambWindow {
764772 items.sort();
765773
766774 state.set(items);
775 state.set_ignorecase(store.application.settings.tunables.ignorecase);
767776
768777 List::new(store)
769778 .empty_message("No in-progress verifications")
src/windows/room/chat.rs +3
@@ -1184,6 +1184,9 @@ impl StatefulWidget for Chat<'_> {
11841184 };
11851185
11861186 let tbox = TextBox::new().prompt(prompt);
1187 state
1188 .tbox
1189 .set_ignorecase(self.store.application.settings.tunables.ignorecase);
11871190 tbox.render(textarea, buf, &mut state.tbox);
11881191
11891192 // Render the message scrollback.
src/windows/room/scrollback.rs +4 −2
@@ -702,7 +702,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
702702 let dir = flip.resolve(&dir);
703703
704704 let lsearch = store.registers.get_last_search().to_string();
705 let needle = Regex::new(lsearch.as_ref())?;
705 let ci = store.application.settings.tunables.ignorecase;
706 let needle = crate::util::compile_search(lsearch.as_ref(), ci)?;
706707
707708 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
708709 if needs_load {
@@ -778,7 +779,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
778779 let dir = flip.resolve(&dir);
779780
780781 let lsearch = store.registers.get_last_search().to_string();
781 let needle = Regex::new(lsearch.as_ref())?;
782 let ci = store.application.settings.tunables.ignorecase;
783 let needle = crate::util::compile_search(lsearch.as_ref(), ci)?;
782784
783785 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
784786 if needs_load {
src/windows/room/space.rs +2
@@ -202,6 +202,8 @@ impl StatefulWidget for Space<'_> {
202202 type State = SpaceState;
203203
204204 fn render(self, area: Rect, buffer: &mut Buffer, state: &mut Self::State) {
205 state.set_ignorecase(self.store.application.settings.tunables.ignorecase);
206
205207 let mut empty_message = None;
206208 let need_fetch = match state.last_fetch {
207209 Some(i) => i.elapsed() >= SPACE_HIERARCHY_DEBOUNCE,
src/windows/welcome.rs +1
@@ -52,6 +52,7 @@ impl TerminalCursor for WelcomeState {
5252
5353impl WindowOps<IambInfo> for WelcomeState {
5454 fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) {
55 self.tbox.set_ignorecase(store.application.settings.tunables.ignorecase);
5556 self.tbox.draw(area, buf, focused, store)
5657 }
5758