From dfef2d2ad83265af3286261d03e2deb5afe6425b Mon Sep 17 00:00:00 2001 From: slava Date: Wed, 22 Nov 2006 02:27:39 +0000 Subject: [PATCH] Slight completion algorithm tweak --- TODO.FACTOR.txt | 4 ---- library/tools/completion.factor | 9 ++++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 71697ed8fe..9d2c8706f6 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -3,12 +3,8 @@ - "ker" C+u: for a moment, full vocab list is shown - some module operations don't work on module-links - list operations: what if nothing is selected? -- list usability - - popup: -- close button - - popup: -- pin button - modules: core/ libs/ apps/ - top level window positioning on ms windows -- completion is not ideal: eg, C+e "buttons" - crashes: - windows gcc issue - robustify stepper -- see if step back past a throw works diff --git a/library/tools/completion.factor b/library/tools/completion.factor index 2d14bf18ba..b30d27254e 100644 --- a/library/tools/completion.factor +++ b/library/tools/completion.factor @@ -55,9 +55,16 @@ USING: kernel arrays sequences math namespaces strings io ; [ first < ] subset-with [ second ] map ; +: complete ( full short -- score ) + #! Match forwards and backwards, see which one has the + #! highest score. + [ dupd fuzzy score ] 2keep + [ ] 2apply + dupd fuzzy score max ; + : completion ( str quot obj -- pair ) #! pair is { obj score } - [ swap call dup rot fuzzy score ] keep 2array ; inline + [ swap call swap complete ] keep 2array ; inline : completions ( str quot candidates -- seq ) pick empty? [