From 3deebc8642927e1595d4d8d62724167c08cf4c42 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 29 Jun 2017 10:53:52 +0100 Subject: [PATCH 1/4] Change the scoring system for autocomplete, scale 0-100 --- .../aceEditor/auto-complete/AutoCompleteManager.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee index cbcdc2eac7..4d71bcc885 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee @@ -93,7 +93,7 @@ define [ caption: "\\#{commandName}{}", snippet: "\\#{commandName}{}", meta: "reference", - score: 11000 + score: 60 } if references.keys and references.keys.length > 0 references.keys.forEach (key) -> @@ -102,7 +102,7 @@ define [ caption: "\\#{commandName}{#{previousArgsCaption}#{key}#{if needsClosingBrace then '}' else ''}", value: "\\#{commandName}{#{previousArgs}#{key}#{if needsClosingBrace then '}' else ''}", meta: "reference", - score: 10000 + score: 50 }) callback null, result else From cbae1857e74a12e1623a6a15020816c50b9d53c8 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 29 Jun 2017 10:54:07 +0100 Subject: [PATCH 2/4] Allow exact match to be ranked higher than any other result --- .../auto-complete/SuggestionManager.coffee | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee index 97241a90ce..bb15035b44 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee @@ -80,7 +80,6 @@ define [], () -> doc = session.getValue() parser = new Parser(doc) commands = parser.parse() - completions = [] for command in commands caption = "\\#{command[0]}" @@ -94,12 +93,12 @@ define [], () -> snippet += "{${#{i}}}" caption += "{}" i++ - unless caption == prefix - completions.push { - caption: caption - snippet: snippet - meta: "cmd" - } + completions.push { + caption: caption + snippet: snippet + meta: "cmd" + score: if prefix == caption then 99 else 50 + } callback null, completions From 936278b04554e670fa493808b4ce9a1fce9704f5 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 29 Jun 2017 10:55:05 +0100 Subject: [PATCH 3/4] Bring score into line with new policy --- .../aceEditor/auto-complete/AutoCompleteManager.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee index 4d71bcc885..f0b23ed8c9 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.coffee @@ -59,14 +59,14 @@ define [ caption: "\\#{commandName}{}", snippet: "\\#{commandName}{}", meta: "cross-reference", - score: 11000 + score: 60 } for label in labelsManager.getAllLabels() result.push { caption: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}", value: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}", meta: "cross-reference", - score: 10000 + score: 50 } callback null, result From c9cda16a5e894f4a70e111aca251d5b7566dd6f4 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 29 Jun 2017 11:13:59 +0100 Subject: [PATCH 4/4] Refactor score calculation --- .../aceEditor/auto-complete/SuggestionManager.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee index bb15035b44..58d53db475 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee @@ -83,6 +83,7 @@ define [], () -> completions = [] for command in commands caption = "\\#{command[0]}" + score = if prefix == caption then 99 else 50 snippet = caption i = 1 _.times command[1], () -> @@ -97,7 +98,7 @@ define [], () -> caption: caption snippet: snippet meta: "cmd" - score: if prefix == caption then 99 else 50 + score: score } callback null, completions