diff --git a/app/assets/javascripts/discourse/app/lib/autocomplete.js b/app/assets/javascripts/discourse/app/lib/autocomplete.js index 974856e5c29..6c4bfc1a2be 100644 --- a/app/assets/javascripts/discourse/app/lib/autocomplete.js +++ b/app/assets/javascripts/discourse/app/lib/autocomplete.js @@ -618,7 +618,7 @@ export default function (options) { break; } } - prevIsGood = !allowedLettersRegex.test(prev); + prevIsGood = !/\s/.test(prev); if (completeTermOption) { prevIsGood ||= prev === " "; } diff --git a/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js b/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js index acfa61dfb2a..eb33b62f11b 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/autocomplete-test.js @@ -66,6 +66,55 @@ module("Unit | Utility | autocomplete", function (hooks) { ); } + test("Autocomplete can complete really short terms correctly", async function (assert) { + let element = textArea(""); + let $element = $(element); + + autocomplete.call($element, { + key: ":", + transformComplete: () => "sad:", + dataSource: () => [":sad:"], + template: compile(`