From 2e0e17f21b868fe0c1a3a4d2d179ba8545dda864 Mon Sep 17 00:00:00 2001 From: Gabeahz Date: Wed, 26 Nov 2025 14:17:27 -0800 Subject: [PATCH 1/4] Improved regex in _validate_value() that checks user input for partition value and unit. - Allows for white space in between groups, aligning better with displayed example. - Removed unneeded | symbol, which was checking as literal rather than working as "or %" --- archinstall/lib/disk/partitioning_menu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archinstall/lib/disk/partitioning_menu.py b/archinstall/lib/disk/partitioning_menu.py index baac9f7745..49e69bc20f 100644 --- a/archinstall/lib/disk/partitioning_menu.py +++ b/archinstall/lib/disk/partitioning_menu.py @@ -437,7 +437,7 @@ def _validate_value( max_size: Size, text: str, ) -> Size | None: - match = re.match(r'([0-9]+)([a-zA-Z|%]*)', text, re.I) + match = re.match(r'^\s*([0-9]+)\s*([a-zA-Z%]*)\s*$', text, re.I) if not match: return None From da81840aff24719501d788bad846f5deb236beb8 Mon Sep 17 00:00:00 2001 From: Gabeahz Date: Mon, 1 Dec 2025 16:54:17 -0800 Subject: [PATCH 2/4] Corrected typos and implements temp menu filtering solution --- archinstall/__init__.py | 2 +- archinstall/lib/global_menu.py | 4 ++-- archinstall/tui/menu_item.py | 24 ++++++++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index 0cd69865b2..ebba9510f7 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -138,7 +138,7 @@ def run_as_a_module() -> None: text = ( 'Archinstall experienced the above error. If you think this is a bug, please report it to\n' 'https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".\n\n' - "Hint: To extract the log from a live ISO \ncurl -F'file=@/var/log/archinstall/install.log' https://0x0.st\n" + "Hint: To extract the log from a live ISO \ncurl -F 'file=@/var/log/archinstall/install.log' https://0x0.st\n" ) warn(text) diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index fa2e51764b..8c13daf402 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -41,10 +41,10 @@ class GlobalMenu(AbstractMenu[None]): def __init__(self, arch_config: ArchConfig) -> None: self._arch_config = arch_config - menu_optioons = self._get_menu_options() + menu_options = self._get_menu_options() self._item_group = MenuItemGroup( - menu_optioons, + menu_options, sort_items=False, checkmarks=True, ) diff --git a/archinstall/tui/menu_item.py b/archinstall/tui/menu_item.py index 741e447d35..62a97b04fa 100644 --- a/archinstall/tui/menu_item.py +++ b/archinstall/tui/menu_item.py @@ -1,5 +1,6 @@ from __future__ import annotations +from _ast import pattern from collections.abc import Callable from dataclasses import dataclass, field from enum import Enum @@ -230,10 +231,25 @@ def set_action_for_all(self, action: Callable[[Any], Any]) -> None: @cached_property def items(self) -> list[MenuItem]: pattern = self._filter_pattern.lower() - items = filter(lambda item: item.is_empty() or pattern in item.text.lower(), self._menu_items) - l_items = list(items) + starts_with_items = list(filter(self._items_startswith(pattern), self._menu_items)) # Working on + contains_items = list(filter(self._items_contains(pattern), self._menu_items)) + l_items = (starts_with_items + contains_items) return l_items + def _items_startswith(self, item: MenuItem, pattern: str) -> bool: + pattern = self._filter_pattern.lower() + + if item.is_empty(): + return True + return item.text.lower().startswith(pattern) + + def _items_contains(self, item: MenuItem, pattern: str) -> bool: + pattern = self._filter_pattern.lower() + + if item.is_empty(): + return True + return pattern in item.text.lower() and not item.text.lower().startswith(pattern) + @property def filter_pattern(self) -> str: return self._filter_pattern @@ -395,7 +411,7 @@ def __init__( self._prev_visible_rows: list[int] = [] self._view_items: list[list[MenuItem]] = [] - def _determine_foucs_row(self) -> int | None: + def _determine_focus_row(self) -> int | None: focus_index = self._item_group.index_focus() if focus_index is None: @@ -406,7 +422,7 @@ def _determine_foucs_row(self) -> int | None: def get_view_items(self) -> list[list[MenuItem]]: enabled_items = self._item_group.get_enabled_items() - focus_row_idx = self._determine_foucs_row() + focus_row_idx = self._determine_focus_row() if focus_row_idx is None: return [] From af6d5b58749435c89b87cf618cb8f42ff0f9b225 Mon Sep 17 00:00:00 2001 From: Gabeahz Date: Tue, 2 Dec 2025 11:30:16 -0800 Subject: [PATCH 3/4] Menu now filters and sorts using priority, improving UX. --- archinstall/tui/menu_item.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/archinstall/tui/menu_item.py b/archinstall/tui/menu_item.py index 62a97b04fa..d309b13e4b 100644 --- a/archinstall/tui/menu_item.py +++ b/archinstall/tui/menu_item.py @@ -1,6 +1,5 @@ from __future__ import annotations -from _ast import pattern from collections.abc import Callable from dataclasses import dataclass, field from enum import Enum @@ -231,24 +230,18 @@ def set_action_for_all(self, action: Callable[[Any], Any]) -> None: @cached_property def items(self) -> list[MenuItem]: pattern = self._filter_pattern.lower() - starts_with_items = list(filter(self._items_startswith(pattern), self._menu_items)) # Working on - contains_items = list(filter(self._items_contains(pattern), self._menu_items)) - l_items = (starts_with_items + contains_items) + items = filter(lambda item: item.is_empty() or pattern in item.text.lower(), self._menu_items) + l_items = sorted(items, key=self._items_score) return l_items - def _items_startswith(self, item: MenuItem, pattern: str) -> bool: + def _items_score(self, item: MenuItem) -> int: pattern = self._filter_pattern.lower() - - if item.is_empty(): - return True - return item.text.lower().startswith(pattern) - - def _items_contains(self, item: MenuItem, pattern: str) -> bool: - pattern = self._filter_pattern.lower() - - if item.is_empty(): - return True - return pattern in item.text.lower() and not item.text.lower().startswith(pattern) + if pattern in item.text.lower(): + if item.text.lower().startswith(pattern): + return 0 + else: + return 1 + return 2 @property def filter_pattern(self) -> str: From 11641eae94066be41ae69b6f5c00fee127424828 Mon Sep 17 00:00:00 2001 From: Gabeahz Date: Tue, 2 Dec 2025 11:40:56 -0800 Subject: [PATCH 4/4] Menu now filters and sorts using priority, improving UX. --- archinstall/__init__.py | 2 +- archinstall/lib/global_menu.py | 4 ++-- archinstall/tui/menu_item.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/archinstall/__init__.py b/archinstall/__init__.py index ebba9510f7..0cd69865b2 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -138,7 +138,7 @@ def run_as_a_module() -> None: text = ( 'Archinstall experienced the above error. If you think this is a bug, please report it to\n' 'https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".\n\n' - "Hint: To extract the log from a live ISO \ncurl -F 'file=@/var/log/archinstall/install.log' https://0x0.st\n" + "Hint: To extract the log from a live ISO \ncurl -F'file=@/var/log/archinstall/install.log' https://0x0.st\n" ) warn(text) diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index 8c13daf402..fa2e51764b 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -41,10 +41,10 @@ class GlobalMenu(AbstractMenu[None]): def __init__(self, arch_config: ArchConfig) -> None: self._arch_config = arch_config - menu_options = self._get_menu_options() + menu_optioons = self._get_menu_options() self._item_group = MenuItemGroup( - menu_options, + menu_optioons, sort_items=False, checkmarks=True, ) diff --git a/archinstall/tui/menu_item.py b/archinstall/tui/menu_item.py index d309b13e4b..6293256c22 100644 --- a/archinstall/tui/menu_item.py +++ b/archinstall/tui/menu_item.py @@ -404,7 +404,7 @@ def __init__( self._prev_visible_rows: list[int] = [] self._view_items: list[list[MenuItem]] = [] - def _determine_focus_row(self) -> int | None: + def _determine_foucs_row(self) -> int | None: focus_index = self._item_group.index_focus() if focus_index is None: @@ -415,7 +415,7 @@ def _determine_focus_row(self) -> int | None: def get_view_items(self) -> list[list[MenuItem]]: enabled_items = self._item_group.get_enabled_items() - focus_row_idx = self._determine_focus_row() + focus_row_idx = self._determine_foucs_row() if focus_row_idx is None: return []