Code Monkey home page Code Monkey logo

flx-rs's Introduction

flx-rs's People

Contributors

jcs090218 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flx-rs's Issues

Implement cache

Original discussed in jcs-elpa/flx-rs#3

Here is another attempt to implement feature cache, see #3. I am not a rust expert, so I always look for improvement or better attempts.

Different scores between implementations

(flx-score
"~/.emacs.d/straight/repos/orderless/orderless.el" "odrless")
(222 26 28 30 31 32 33 34)

(flx-score
"Code/Everyone/Xamarin/EMJavaBindings/EMJavaBindings/Additions/DrawableSoftReference.cs"
"odrless")
(138 1 62 63 68 69 70 85)

(flx-rs-score
"~/.emacs.d/straight/repos/orderless/orderless.el" "odrless")
(112 23 28 30 31 32 33 34)

(flx-rs-score
"Code/Everyone/Xamarin/EMJavaBindings/EMJavaBindings/Additions/DrawableSoftReference.cs"
"odrless")
(180 1 62 63 68 69 70 85)

`fn score` panics if query char not in search string

A simple query like

#[test]
fn test() { score("Test", "d"); }

panics in find_best_match when trying to find "d" in str_info.

#[test]
fn test() { score("Testd", "d"); }

works since then str_info built from the search string contains the query string char(s).

Seems like a pretty straight forward bug. But I didn't really dig enough into the code to know what the right fix would be.

Expose a way to use filetype heatmap function

We may want to expose a way somehow (maybe (Score( str: &str, query: &str, group-separator: &str))) so that the heatmap fn can boost the score of file/directory names.

pub fn get_heatmap_str(scores: &mut Vec<i32>, str: &str, group_separator: Option<char>) {

Original flx implements this through setting up the heatmap-fn on the file cache that's created.

https://github.com/lewang/flx/blob/e3b3f0533e44c5250ce73d728b59a7e96c692b5d/flx.el#L232
(defun flx-get-heatmap-file (filename)
  "Return heatmap vector for filename."
  (flx-get-heatmap-str filename ?/))

If we had the cache (and we're ok with not exposing the cache to elisp), we could add an extra param/boolean? to flx-rs-score like

(flx-rs-score x string USE-FILESYSTEM-HEATMAP-FN)

for it to autopick the right heatmap function in score.

If we have a cache and we are exposing that cache to elisp, it would probably suffice to have the elisp side pass the map over. I think this might be tricky though since the cache that's in elisp resembles more of an object than a true hashmap. (It's more like an object that contains a cache, a heatmap, and a heatmap-fn).

If we don't have the cache, it may make sense to allow the score function take in a group-separator string (or list of strings/not super sure if that makes sense).

e.g.

(flx-rs-score x string GROUP-SEPERATOR-CHAR)

Overflow on longer strings

Rust panics with
thread 'test_nok' panicked at 'attempt to multiply with overflow', src/search.rs:256:40
on longer strings. Maybe somewhat surprisingly, both the query as well as the search string seem to contribute to this panic.

#[test]
fn test_ok() {// base, works
    let s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
    score(s, "ABCDE");
}

#[test]
fn test_ok2() {// s increased by one, query reduced by one, still works
    let s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890A";
    score(s, "ABCD");
}

#[test]
fn test_panic() {// s increased by one, query left as is, panics
    let s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890A";
    score(s, "ABCDE");
}

I'm not sure whether only short strings are supported or this is a legit bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.