From 68b57f8d9570c374638b205baff4f23f6ba1b83a Mon Sep 17 00:00:00 2001 From: Nate Stemen Date: Tue, 12 Dec 2017 14:33:11 -0500 Subject: [PATCH 1/4] check current commands against package commands --- .../directives/aceEditor/auto-complete/CommandManager.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee index 07ca3d2ecb..fc21f65455 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee @@ -101,6 +101,7 @@ define [ for pkg, snippets of packages for snippet in snippets packageCommands.push snippet + commandNames.push snippet.caption.match(/\w+/)[0] doc = session.getValue() parser = new Parser(doc, prefix) From 7d5c661b4eb20e3dd12b3c3e596ce47658bb121a Mon Sep 17 00:00:00 2001 From: Nate Stemen Date: Fri, 15 Dec 2017 11:10:44 -0500 Subject: [PATCH 2/4] make command names local array --- .../aceEditor/auto-complete/CommandManager.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee index fc21f65455..a3f1c965d4 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee @@ -2,8 +2,6 @@ define [ "./top_hundred_snippets" ], (topHundred) -> - commandNames = (snippet.caption.match(/\w+/)[0] for snippet in topHundred) - class Parser constructor: (@doc, @prefix) -> @@ -96,6 +94,10 @@ define [ constructor: (@metadataManager) -> getCompletions: (editor, session, pos, prefix, callback) -> + console.log '>> this is running!' + commandNames = ( + snippet.caption.match(/\w+/)[0] for snippet in topHundred + ) packages = @metadataManager.getAllPackages() packageCommands = [] for pkg, snippets of packages From 685595ed0a157861f4905b409262fa20fd979d64 Mon Sep 17 00:00:00 2001 From: Nate Stemen Date: Tue, 19 Dec 2017 08:44:19 -0500 Subject: [PATCH 3/4] remove comment --- .../directives/aceEditor/auto-complete/CommandManager.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee index a3f1c965d4..f5ef3cc5d5 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee @@ -94,7 +94,6 @@ define [ constructor: (@metadataManager) -> getCompletions: (editor, session, pos, prefix, callback) -> - console.log '>> this is running!' commandNames = ( snippet.caption.match(/\w+/)[0] for snippet in topHundred ) From d2ee03d9b9e592a9805f329a30f4546b34f660d6 Mon Sep 17 00:00:00 2001 From: Nate Stemen Date: Thu, 21 Dec 2017 15:51:50 -0500 Subject: [PATCH 4/4] make commandNames object for fast lookups --- .../aceEditor/auto-complete/CommandManager.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee index f5ef3cc5d5..d194c7fb4a 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee @@ -94,22 +94,23 @@ define [ constructor: (@metadataManager) -> getCompletions: (editor, session, pos, prefix, callback) -> - commandNames = ( - snippet.caption.match(/\w+/)[0] for snippet in topHundred - ) + commandNames = {} + for snippet in topHundred + commandNames[snippet.caption.match(/\w+/)[0]] = true + packages = @metadataManager.getAllPackages() packageCommands = [] for pkg, snippets of packages for snippet in snippets packageCommands.push snippet - commandNames.push snippet.caption.match(/\w+/)[0] + commandNames[snippet.caption.match(/\w+/)[0]] = true doc = session.getValue() parser = new Parser(doc, prefix) commands = parser.parse() completions = [] for command in commands - if command[0] not in commandNames + if not commandNames[command[0]] caption = "\\#{command[0]}" score = if caption == prefix then 99 else 50 snippet = caption