From feb736c1bcfbbea49bc271db525fd69344ef5add Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 28 Mar 2018 15:54:28 -0400 Subject: [PATCH] Always show all autocomplete items (Fixes #833) --- .../components/codemirror/extensions/autocomplete.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js b/packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js index 5427d424d7..dd7545e898 100644 --- a/packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js +++ b/packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js @@ -8,7 +8,7 @@ const NAME_MATCH = /[\w.\][]+$/; const AFTER_VARIABLE_MATCH = /{{\s*[\w.\][]*$/; const AFTER_TAG_MATCH = /{%\s*[\w.\][]*$/; const COMPLETE_AFTER_WORD = /[\w.\][-]+/; -const COMPLETE_AFTER_CURLIES = /[^{]*\{[{%]\s*/; +const COMPLETE_AFTER_CURLIES = /[^{]*{[{%]\s*/; const COMPLETION_CLOSE_KEYS = /[}|-]/; const MAX_HINT_LOOK_BACK = 100; const HINT_DELAY_MILLIS = 700; @@ -227,13 +227,9 @@ function hint (cm, options) { .map(m => allLongMatches.push(m)); } - /* - * If anything matched the longer segment, only return those. Otherwise return only - * the short form. For example, if the long form is "application/json" and short is "json", - * prioritise matches form "application/json" if there were any. - */ - const matches = allLongMatches.length ? allLongMatches : allShortMatches; - const segment = allLongMatches.length ? nameSegmentLong : nameSegment; + // NOTE: This puts the longer (more precise) matches in front of the short ones + const matches = [...allLongMatches, ...allShortMatches]; + const segment = [...nameSegmentLong, nameSegment]; return { list: matches,