From d549659f1e33952a6d2ef45593b4cd31978fa664 Mon Sep 17 00:00:00 2001 From: QC Date: Thu, 9 Jul 2015 20:44:12 +0200 Subject: [PATCH] Use right modifier --- source/i3-support.c | 2 +- source/rofi.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/i3-support.c b/source/i3-support.c index c4759bbb..dc37b2e3 100644 --- a/source/i3-support.c +++ b/source/i3-support.c @@ -57,7 +57,7 @@ void i3_support_focus_window ( Window id ) char command[upm]; if ( strlen ( i3_socket_path ) > upm ) { - fprintf ( stderr, "Socket path is too long. %zd > %lu\n", strlen ( i3_socket_path ), upm ); + fprintf ( stderr, "Socket path is too long. %zd > %zd\n", strlen ( i3_socket_path ), upm ); return; } diff --git a/source/rofi.c b/source/rofi.c index 9c4df719..f524d00c 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -727,7 +727,17 @@ static void menu_refilter ( MenuState *state, char **lines, menu_match_cb mmc, v if ( match ) { state->line_map[j] = i; if ( sorting ) { - state->distance[i] = levenshtein ( state->text->text, lines[i] ); + state->distance[i] = 0; + char **words = tokenize ( lines[i], case_sensitive ); + for( int k = 0; tokens && tokens[k]; k++) { + for ( int j = 0; words && words[j]; j++) { + if (strcasecmp ( tokens[k], words[j] ) != 0) + state->distance[i] += levenshtein ( tokens[k], words[j] ) * strlen(tokens[k]); + else + state->distance[i] -= strlen (tokens[k]) << 1; + } + } + g_strfreev ( words ); } j++; }