mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Ignore Arabic short vowels and shadda in chat autocomplete
Arabic catalog strings carry optional marks ("تتبّع"), but people type
without them, so "تتبع" found no suggestion. Fold the marks out of both
the draft and the candidates before comparing.
This commit is contained in:
1 parent
cd7c5d5a17
commit
06c84f92d3
2 files changed
+25
-6
No files matched your search
@@ -22,6 +22,10 @@ export function bindChatPreferences({ ui, getDraft, setDraft }) {
|
||||
msg('Reset to globe view'),
|
||||
msg('Show earthquakes'),
|
||||
].map((text) => t(text));
|
||||
// Arabic short vowels and shadda are optional in writing: typing "تتبع"
|
||||
// still finds "تتبّع".
|
||||
const fold = (text) =>
|
||||
text.toLowerCase().replace(/[\u064B-\u065F\u0670]/g, '');
|
||||
try {
|
||||
const stored = JSON.parse(localStorage.getItem(key));
|
||||
if (typeof stored?.quick === 'boolean') quick = stored.quick;
|
||||
@@ -31,18 +35,14 @@ export function bindChatPreferences({ ui, getDraft, setDraft }) {
|
||||
function render() {
|
||||
const draft = getDraft();
|
||||
if (historyIndex >= 0 && draft !== recent[historyIndex]) resetHistory();
|
||||
const query = draft.trim().toLowerCase();
|
||||
const query = fold(draft.trim());
|
||||
const groups = [];
|
||||
if (query) {
|
||||
const candidates = [...recent, ...(quick ? quickCommands() : [])];
|
||||
groups.push({
|
||||
label: t('Suggestions'),
|
||||
items: [...new Set(candidates)]
|
||||
.filter(
|
||||
(text) =>
|
||||
text.toLowerCase().includes(query) &&
|
||||
text.toLowerCase() !== query,
|
||||
)
|
||||
.filter((text) => fold(text).includes(query) && fold(text) !== query)
|
||||
.slice(0, 4),
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user