public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Nicolas Frey <n.frey@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [PATCH proxmox-yew-widget-toolkit 1/5] widget: data table: simplify lookup of keys near the cursor
Date: Wed, 28 Oct 2026 16:15:11 +0100	[thread overview]
Message-ID: <20261028151517.518742-2-n.frey@proxmox.com> (raw)
In-Reply-To: <20261028151517.518742-1-n.frey@proxmox.com>

Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
---
 src/widget/data_table/data_table.rs | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/src/widget/data_table/data_table.rs b/src/widget/data_table/data_table.rs
index 5d04173..e846522 100644
--- a/src/widget/data_table/data_table.rs
+++ b/src/widget/data_table/data_table.rs
@@ -620,27 +620,16 @@ impl<S: DataStore> PwtDataTable<S> {
     // avoid slow search by lookup up keys nearby cursor first
     fn filtered_record_pos(&self, props: &DataTable<S>, key: &Key) -> Option<usize> {
         if let Some(Cursor { pos, .. }) = &self.cursor {
-            let test_pos = *pos;
-            if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) {
-                if &record_key == key {
+            for test_pos in [Some(*pos), pos.checked_add(1), pos.checked_sub(1)]
+                .into_iter()
+                .flatten()
+            {
+                if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos)
+                    && &record_key == key
+                {
                     return Some(test_pos);
                 }
             }
-
-            let test_pos = pos + 1;
-            if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) {
-                if &record_key == key {
-                    return Some(test_pos);
-                }
-            }
-            if *pos > 0 {
-                let test_pos = pos - 1;
-                if let Some(record_key) = props.store.lookup_filtered_record_key(test_pos) {
-                    if &record_key == key {
-                        return Some(test_pos);
-                    }
-                }
-            }
         }
 
         props.store.filtered_record_pos(key)
-- 
2.47.3





  reply	other threads:[~2026-10-28 15:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 15:15 [PATCH proxmox-yew-widget-toolkit 0/5] add multi-select component Nicolas Frey
2026-10-28 15:15 ` Nicolas Frey [this message]
2026-10-28 15:15 ` [PATCH proxmox-yew-widget-toolkit 2/5] widget: data table: only extend explicit select all to new rows Nicolas Frey
2026-10-28 15:15 ` [PATCH proxmox-yew-widget-toolkit 3/5] widget: grid picker: keep selected records hidden by the filter Nicolas Frey
2026-10-28 15:15 ` [PATCH proxmox-yew-widget-toolkit 4/5] widget: form: implement multi select field Nicolas Frey
2026-10-28 15:15 ` [PATCH proxmox-yew-widget-toolkit 5/5] widget: form: combobox: update doc to point to `MultiSelect` Nicolas Frey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261028151517.518742-2-n.frey@proxmox.com \
    --to=n.frey@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal