Skip to content

fix: linux app search#389

Merged
SteveLauC merged 1 commit intomainfrom
steve/fix/linux_app_search
Apr 18, 2025
Merged

fix: linux app search#389
SteveLauC merged 1 commit intomainfrom
steve/fix/linux_app_search

Conversation

@SteveLauC
Copy link
Copy Markdown
Member

@SteveLauC SteveLauC commented Apr 18, 2025

What does this PR do

Fix the app search on Linux:

  1. Correct the displayed app name
  2. Add support for apps installed via Flatpak

Rationale for this change

Standards checklist

  • The PR title is descriptive
  • The commit messages are semantic
  • Necessary tests are added
  • Updated the release notes
  • Necessary documents have been added if this is a new feature
  • Performance tests checked, no obvious performance degradation

@SteveLauC SteveLauC requested a review from Copilot April 18, 2025 03:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses issues with app search on Linux by correcting the displayed app name and adding support for apps installed via Flatpak.

  • Added helper functions to retrieve app paths, names, and icon paths.
  • Changed the fuzzy search distance to be based on the query string length and updated the Trie key type.
  • Updated the applications dependency revision in Cargo.toml.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src-tauri/src/local/application.rs Refactored helper functions and search logic for Linux app support and fuzzy search improvements.
src-tauri/Cargo.toml Updated the applications-rs dependency revision.

Comment on lines 258 to +260
let mut results = self
.application_paths
.search_within_distance_scored(&query_string, 3);
.search_within_distance_scored(&query_string, query_string_len - 1);
Copy link

Copilot AI Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure query_string is not empty before subtracting 1 from its length to avoid potential underflow. Consider adding a check to use a safe default when query_string is empty.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See:

        if query_string.is_empty() {
            return Ok(QueryResponse {
                source: self.get_type(),
                hits: Vec::new(),
                total_hits: 0,
            });
        }

// app name -> app icon path
icons: HashMap<String, PathBuf>,
application_paths: Trie<String>,
application_paths: Trie<PathBuf>,
Copy link

Copilot AI Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Trie key type has been changed to PathBuf, but fuzzy search is performed using app names (String). Consider reverting the Trie key type back to String or converting PathBuf to String for consistency in fuzzy search.

Suggested change
application_paths: Trie<PathBuf>,
application_paths: Trie<String>,

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Trie key type has been changed to PathBuf

Trie, T is the type of the value, not the key. See https://docs.rs/fuzzy_prefix_search/latest/fuzzy_prefix_search/trie/struct.Trie.html#method.insert

@SteveLauC SteveLauC merged commit 20e8658 into main Apr 18, 2025
@SteveLauC SteveLauC deleted the steve/fix/linux_app_search branch April 18, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants