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"
10default_room = "#iamb-users:0x.badd.cafe" 10default_room = "#iamb-users:0x.badd.cafe"
11default_split = "vertical" 11default_split = "vertical"
12external_edit_file_suffix = ".md" 12external_edit_file_suffix = ".md"
13ignorecase = false
13log_level = "warn" 14log_level = "warn"
14members_split = "vertical" 15members_split = "vertical"
15message_shortcode_display = false 16message_shortcode_display = false
docs/iamb.5 +2
@@ -164,6 +164,8 @@ Suffix to append to temporary file names when using the :editor command. Default
164Subsection for configuring image previews. See 164Subsection for configuring image previews. See
165.Sx "IMAGE PREVIEWS" 165.Sx "IMAGE PREVIEWS"
166for more details. 166for more details.
167.It Sy ignorecase
168Defines whether searches ignore case. Defaults to false.
167.It Sy log_level 169.It Sy log_level
168Specifies the lowest log level that should be shown. 170Specifies the lowest log level that should be shown.
169Possible values are: 171Possible values are:
src/config.rs +4
@@ -815,6 +815,7 @@ pub struct TerminalValues {
815pub struct TunableValues { 815pub struct TunableValues {
816 pub encryption: EncryptionValues, 816 pub encryption: EncryptionValues,
817 pub default_markup: MarkupFormat, 817 pub default_markup: MarkupFormat,
818 pub ignorecase: bool,
818 pub log_level: String, 819 pub log_level: String,
819 pub max_log_files: usize, 820 pub max_log_files: usize,
820 pub message_shortcode_display: bool, 821 pub message_shortcode_display: bool,
@@ -869,6 +870,7 @@ pub struct Tunables {
869 pub users: Option<UserOverrides>, 870 pub users: Option<UserOverrides>,
870 871
871 pub default_markup: Option<MarkupFormat>, 872 pub default_markup: Option<MarkupFormat>,
873 pub ignorecase: Option<bool>,
872 pub log_level: Option<String>, 874 pub log_level: Option<String>,
873 pub max_log_files: Option<usize>, 875 pub max_log_files: Option<usize>,
874 pub message_shortcode_display: Option<bool>, 876 pub message_shortcode_display: Option<bool>,
@@ -912,6 +914,7 @@ impl Tunables {
912 proxy: self.proxy.or(other.proxy), 914 proxy: self.proxy.or(other.proxy),
913 915
914 default_markup: self.default_markup.or(other.default_markup), 916 default_markup: self.default_markup.or(other.default_markup),
917 ignorecase: self.ignorecase.or(other.ignorecase),
915 log_level: self.log_level.or(other.log_level), 918 log_level: self.log_level.or(other.log_level),
916 max_log_files: self.max_log_files.or(other.max_log_files), 919 max_log_files: self.max_log_files.or(other.max_log_files),
917 message_shortcode_display: self 920 message_shortcode_display: self
@@ -958,6 +961,7 @@ impl Tunables {
958 961
959 default_markup: self.default_markup.unwrap_or_default(), 962 default_markup: self.default_markup.unwrap_or_default(),
960 log_level: self.log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL.to_owned()), 963 log_level: self.log_level.unwrap_or_else(|| DEFAULT_LOG_LEVEL.to_owned()),
964 ignorecase: self.ignorecase.unwrap_or(false),
961 max_log_files: self.max_log_files.unwrap_or(7), 965 max_log_files: self.max_log_files.unwrap_or(7),
962 message_shortcode_display: self.message_shortcode_display.unwrap_or(false), 966 message_shortcode_display: self.message_shortcode_display.unwrap_or(false),
963 normal_after_send: self.normal_after_send.unwrap_or(false), 967 normal_after_send: self.normal_after_send.unwrap_or(false),
src/tests.rs +1
@@ -167,6 +167,7 @@ pub fn mock_dirs() -> DirectoryValues {
167pub fn mock_tunables() -> TunableValues { 167pub fn mock_tunables() -> TunableValues {
168 TunableValues { 168 TunableValues {
169 default_markup: Default::default(), 169 default_markup: Default::default(),
170 ignorecase: false,
170 default_room: None, 171 default_room: None,
171 encryption: Encryption::default().values(), 172 encryption: Encryption::default().values(),
172 log_level: "warn".into(), 173 log_level: "warn".into(),
src/util.rs +19
@@ -1,6 +1,7 @@
1//! # Utility functions 1//! # Utility functions
2use std::borrow::Cow; 2use std::borrow::Cow;
3 3
4use regex::{Regex, RegexBuilder};
4use unicode_segmentation::UnicodeSegmentation; 5use unicode_segmentation::UnicodeSegmentation;
5use unicode_width::UnicodeWidthStr; 6use unicode_width::UnicodeWidthStr;
6 7
@@ -182,10 +183,28 @@ pub fn replace_emojis_in_line(line: &mut Line) {
182 } 183 }
183} 184}
184 185
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
185#[cfg(test)] 191#[cfg(test)]
186pub mod tests { 192pub mod tests {
187 use super::*; 193 use super::*;
188 194
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
189 #[test] 208 #[test]
190 fn test_wrapped_lines_ascii() { 209 fn test_wrapped_lines_ascii() {
191 let s = "hello world!\nabcdefghijklmnopqrstuvwxyz\ngoodbye"; 210 let s = "hello world!\nabcdefghijklmnopqrstuvwxyz\ngoodbye";
src/windows/mod.rs +9
@@ -584,6 +584,7 @@ impl WindowOps<IambInfo> for IambWindow {
584 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); 584 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
585 585
586 state.set(items); 586 state.set(items);
587 state.set_ignorecase(store.application.settings.tunables.ignorecase);
587 588
588 List::new(store) 589 List::new(store)
589 .empty_message("No direct messages yet!") 590 .empty_message("No direct messages yet!")
@@ -608,6 +609,8 @@ impl WindowOps<IambInfo> for IambWindow {
608 *last_fetch = Some(Instant::now()); 609 *last_fetch = Some(Instant::now());
609 } 610 }
610 611
612 state.set_ignorecase(store.application.settings.tunables.ignorecase);
613
611 List::new(store) 614 List::new(store)
612 .empty_message("No users here yet!") 615 .empty_message("No users here yet!")
613 .empty_alignment(Alignment::Center) 616 .empty_alignment(Alignment::Center)
@@ -628,6 +631,7 @@ impl WindowOps<IambInfo> for IambWindow {
628 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); 631 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
629 632
630 state.set(items); 633 state.set(items);
634 state.set_ignorecase(store.application.settings.tunables.ignorecase);
631 635
632 List::new(store) 636 List::new(store)
633 .empty_message("You haven't joined any rooms yet") 637 .empty_message("You haven't joined any rooms yet")
@@ -660,6 +664,7 @@ impl WindowOps<IambInfo> for IambWindow {
660 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); 664 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
661 665
662 state.set(items); 666 state.set(items);
667 state.set_ignorecase(store.application.settings.tunables.ignorecase);
663 668
664 List::new(store) 669 List::new(store)
665 .empty_message("You do not have rooms or dms yet") 670 .empty_message("You do not have rooms or dms yet")
@@ -694,6 +699,7 @@ impl WindowOps<IambInfo> for IambWindow {
694 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); 699 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
695 700
696 state.set(items); 701 state.set(items);
702 state.set_ignorecase(store.application.settings.tunables.ignorecase);
697 703
698 List::new(store) 704 List::new(store)
699 .empty_message("You do not have any unreads yet") 705 .empty_message("You do not have any unreads yet")
@@ -728,6 +734,7 @@ impl WindowOps<IambInfo> for IambWindow {
728 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); 734 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
729 735
730 state.set(items); 736 state.set(items);
737 state.set_ignorecase(store.application.settings.tunables.ignorecase);
731 738
732 List::new(store) 739 List::new(store)
733 .empty_message("You do not have any unread mentions yet") 740 .empty_message("You do not have any unread mentions yet")
@@ -749,6 +756,7 @@ impl WindowOps<IambInfo> for IambWindow {
749 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator)); 756 items.sort_by(|a, b| room_fields_cmp(a, b, fields, collator));
750 757
751 state.set(items); 758 state.set(items);
759 state.set_ignorecase(store.application.settings.tunables.ignorecase);
752 760
753 List::new(store) 761 List::new(store)
754 .empty_message("You haven't joined any spaces yet") 762 .empty_message("You haven't joined any spaces yet")
@@ -764,6 +772,7 @@ impl WindowOps<IambInfo> for IambWindow {
764 items.sort(); 772 items.sort();
765 773
766 state.set(items); 774 state.set(items);
775 state.set_ignorecase(store.application.settings.tunables.ignorecase);
767 776
768 List::new(store) 777 List::new(store)
769 .empty_message("No in-progress verifications") 778 .empty_message("No in-progress verifications")
src/windows/room/chat.rs +3
@@ -1184,6 +1184,9 @@ impl StatefulWidget for Chat<'_> {
1184 }; 1184 };
1185 1185
1186 let tbox = TextBox::new().prompt(prompt); 1186 let tbox = TextBox::new().prompt(prompt);
1187 state
1188 .tbox
1189 .set_ignorecase(self.store.application.settings.tunables.ignorecase);
1187 tbox.render(textarea, buf, &mut state.tbox); 1190 tbox.render(textarea, buf, &mut state.tbox);
1188 1191
1189 // Render the message scrollback. 1192 // Render the message scrollback.
src/windows/room/scrollback.rs +4 −2
@@ -702,7 +702,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
702 let dir = flip.resolve(&dir); 702 let dir = flip.resolve(&dir);
703 703
704 let lsearch = store.registers.get_last_search().to_string(); 704 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)?;
706 707
707 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info); 708 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
708 if needs_load { 709 if needs_load {
@@ -778,7 +779,8 @@ impl EditorActions<ProgramContext, ProgramStore, IambInfo> for ScrollbackState {
778 let dir = flip.resolve(&dir); 779 let dir = flip.resolve(&dir);
779 780
780 let lsearch = store.registers.get_last_search().to_string(); 781 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)?;
782 784
783 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info); 785 let (mc, needs_load) = self.find_message(key, dir, &needle, count, info);
784 if needs_load { 786 if needs_load {
src/windows/room/space.rs +2
@@ -202,6 +202,8 @@ impl StatefulWidget for Space<'_> {
202 type State = SpaceState; 202 type State = SpaceState;
203 203
204 fn render(self, area: Rect, buffer: &mut Buffer, state: &mut Self::State) { 204 fn render(self, area: Rect, buffer: &mut Buffer, state: &mut Self::State) {
205 state.set_ignorecase(self.store.application.settings.tunables.ignorecase);
206
205 let mut empty_message = None; 207 let mut empty_message = None;
206 let need_fetch = match state.last_fetch { 208 let need_fetch = match state.last_fetch {
207 Some(i) => i.elapsed() >= SPACE_HIERARCHY_DEBOUNCE, 209 Some(i) => i.elapsed() >= SPACE_HIERARCHY_DEBOUNCE,
src/windows/welcome.rs +1
@@ -52,6 +52,7 @@ impl TerminalCursor for WelcomeState {
52 52
53impl WindowOps<IambInfo> for WelcomeState { 53impl WindowOps<IambInfo> for WelcomeState {
54 fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) { 54 fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) {
55 self.tbox.set_ignorecase(store.application.settings.tunables.ignorecase);
55 self.tbox.draw(area, buf, focused, store) 56 self.tbox.draw(area, buf, focused, store)
56 } 57 }
57 58