mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
composebox_typeahead: Fix topic completion broken for long stream names.
Previous value of `40` didn't account for full length of stream name which results in topic completion not working for stream names bigger than that.
This commit is contained in:
@@ -43,6 +43,9 @@ import type {UserPillData} from "./user_pill.ts";
|
||||
import {user_settings} from "./user_settings.ts";
|
||||
import * as util from "./util.ts";
|
||||
|
||||
/* Maximum channel name length + link syntax (#**>**) + some topic characters */
|
||||
const MAX_LOOKBACK_FOR_TYPEAHEAD_COMPLETION = 60 + 6 + 20;
|
||||
|
||||
// **********************************
|
||||
// AN IMPORTANT NOTE ABOUT TYPEAHEADS
|
||||
// **********************************
|
||||
@@ -423,7 +426,7 @@ export function tokenize_compose_str(s: string): string {
|
||||
|
||||
// We limit how far back to scan to limit potential weird behavior
|
||||
// in very long messages, and simplify performance analysis.
|
||||
let min_i = s.length - 40;
|
||||
let min_i = s.length - MAX_LOOKBACK_FOR_TYPEAHEAD_COMPLETION;
|
||||
if (min_i < 0) {
|
||||
min_i = 0;
|
||||
}
|
||||
|
@@ -2014,7 +2014,12 @@ test("tokenizing", () => {
|
||||
|
||||
// The following cases are kinda judgment calls...
|
||||
// max scanning limit is 40 characters until chars like @, # , / are found
|
||||
assert.equal(ct.tokenize_compose_str("foo @toomanycharactersistooridiculoustocomplete"), "");
|
||||
assert.equal(
|
||||
ct.tokenize_compose_str(
|
||||
"foo @toomanycharactersistooridiculoustoautocompletethatitexceedsalllimits",
|
||||
),
|
||||
"",
|
||||
);
|
||||
assert.equal(ct.tokenize_compose_str("foo #bar@foo"), "#bar@foo");
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user