Commit Graph

19 Commits

Author SHA1 Message Date
Azat Khuzhin
177c98b6a9 Use "exact" matching for fuzzy search
Right now fuzzy search is too smart for SQL, it even takes into account
the case, which should not be accounted (you don't want to type "SELECT"
instead of "select" to find the query).

And to tell the truth, I think too smart fuzzy searching for SQL queries
is not required, and is only harming.

Exact matching seems better algorithm for SQL, it is not 100% exact, it
splits by space, and apply separate matcher actually for each word.
Note, that if you think that "space is not enough" as the delimiter,
then you should first know that this is the delimiter only for the
input query, so to match "system.query_log" you can use "sy qu log"
(also you can disable exact mode by prepending "'" char).

But it ignores the case by default, and the behaviour what is expected
from the CaseMatching::Ignore.

TL;DR;

Just for the history I will describe what had been tried.

At first I tried CaseMatching::Ignore - it does not helps for
SkimV1/SkimV2/Clangd matches.

So I converted lines from the history and input query, to the lower
case. However this does not work for UPPER CASE, since only initial
portion of the query had been converted to the lower.

Then I've looked into skim/fuzzy-matcher crates code, and look for the
reason why CaseMatching::Ignore does not work, and found that there is
still a penalty for case mismatch, but there is no way to pass it from
the user code, so I've tried guerrilla to monkey patch the library's
code and it works:

    // Avoid penalty for case mismatch (even with CaseMatching::Ignore)
    let _guard = guerrilla::patch0(SkimScoreConfig::default, || {
        let score_match = 16;
        let gap_start = -3;
        let gap_extension = -1;
        let bonus_first_char_multiplier = 2;

        return SkimScoreConfig{
            score_match,
            gap_start,
            gap_extension,
            bonus_first_char_multiplier,
            bonus_head: score_match / 2,
            bonus_break: score_match / 2 + gap_extension,
            bonus_camel: score_match / 2 + 2 * gap_extension,
            bonus_consecutive: -(gap_start + gap_extension),
            // penalty_case_mismatch: gap_extension * 2,
            penalty_case_mismatch: 0,
        };
    });

But this does not sounds like a trivial code, so I decided, to look
around, and realized that "exact" matching should do what is required
for the completion of queries (at least from my point of view).

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-02-04 14:15:02 +01:00
Azat Khuzhin
780c8ea586 Avoid leaving symbols leftovers on the screen during query fuzzy search
In case of multi-line queries in the history, skim may leave some
symbols on the screen, which looks icky.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-02-02 19:31:45 +01:00
Robert Schulze
cfb6feffde
What happens if I remove these 139 lines of code? 2023-01-03 18:35:31 +00:00
Azat Khuzhin
89c071e291 Build rust modules from the binary directory
Our crates has configuration files:
- config for cargo (see config.toml.in)
- and possibly config for build (build.rs.in)

Previously it uses source directory, and it will overrides files in the
source directory, which will require recompile of crates in case of
multiple builds for one source directory.

To avoid overlaps different builds for one source directory, crate will
be copied from source directory to the binary directory.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-30 18:15:41 +01:00
Alexey Milovidov
ed3d70f7c0
Merge pull request #44623 from azat/build/rust-fix
Fix rust modules rebuild (previously ignores changes in cargo config.toml)
2022-12-27 17:10:33 +03:00
Azat Khuzhin
72d102d94c Fix rust modules rebuild (previously ignores changes in cargo config.toml)
This leads to the problem when you switch compiler flags, for example:

    $ cmake -DSANITIZE=memory ..
    $ ninja
    $ cmake -DSANITIZE= ..
    $ ninja

And this leads to:

    ld.lld-15: error: undefined symbol: __msan_init
    >>> referenced by lib.rs.cc
    >>>               lib.rs.o:(msan.module_ctor) in archive rust/skim/RelWithDebInfo/lib_ch_rust_skim_rust.a

Reported-by: @alexey-milovidov
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-27 10:35:50 +01:00
Azat Khuzhin
4d17510fca Use already written part of the query for fuzzy search (pass to skim)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-26 14:52:38 +01:00
Azat Khuzhin
cf0e0436be skim: do not panic if terminal is not available
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-14 21:01:48 +01:00
Azat Khuzhin
e7c5b48d84 rust: fix buidling modules with CMAKE_BUILD_TYPE in a different case
Before this patch corrosion requires that CMAKE_BUILD_TYPE matches the
CMAKE_CONFIGURATION_TYPES, which is
"RelWithDebInfo;Debug;Release;MinSizeRel", so that said, that if you
were using CMAKE_BUILD_TYPE=debug, it will not work.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-14 20:58:34 +01:00
Azat Khuzhin
f8c17d4a66 rust: reuse RUST_CXXFLAGS for skim
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-14 20:58:17 +01:00
Azat Khuzhin
82aaad61aa Integrate skim into the client/local
Note, that it can the fail the client if the skim itself will fail,
however I haven't seen it panicd, so let's try.

P.S. about adding USE_SKIM into configure header instead of just compile
option for target, it is better, because it allows not to recompile lots
of C++ headers, since we have to add skim library as PUBLIC. But anyway
this will be resolved in a different way, but separatelly.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-14 20:57:41 +01:00
Azat Khuzhin
28737a503c Configure rustc compiler properly
Right now it works for host platforms because of gcc package, that
includes gcc-cross sysroot.

Use bundled sysroot from contrib instead.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-14 20:57:29 +01:00
Azat Khuzhin
f2264bf9b0 rust/BLAKE3: remove eXecutable bit from CMakeLists
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-14 20:57:11 +01:00
Azat Khuzhin
67fa185611
Revert "Builtin skim" 2022-12-14 17:17:19 +03:00
Azat Khuzhin
de58e9c02d Integrate skim into the client/local
Note, that it can the fail the client if the skim itself will fail,
however I haven't seen it panicd, so let's try.

P.S. about adding USE_SKIM into configure header instead of just compile
option for target, it is better, because it allows not to recompile lots
of C++ headers, since we have to add skim library as PUBLIC.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-11 15:52:00 +01:00
Azat Khuzhin
8570f15688 Configure rustc compiler properly
Right now it works for host platforms because of gcc package, that
includes gcc-cross sysroot.

Use bundled sysroot from contrib instead.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-11 15:52:00 +01:00
Azat Khuzhin
e6720689fc rust/blak3: remove eXecutable bit from CMakeLists
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-12-11 15:51:37 +01:00
BoloniniD
0df426d329 Corrosion fixes + review fixes 2022-09-16 00:05:21 +03:00
BoloniniD
147dfac11e Try using Corrosion 2022-09-12 23:05:41 +03:00