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
@@ -1,5 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { bindChatPreferences } from './chatPreferences.js';
|
||||
import { createTestVoiceUi } from '../testSupport/voiceUi.mjs';
|
||||
|
||||
@@ -99,3 +100,21 @@ test('editing a recalled message ends recall, and sending resets it', (t) => {
|
||||
press('ArrowUp');
|
||||
assert.equal(field.value, 'Show live flights now');
|
||||
});
|
||||
|
||||
test('autocomplete ignores Arabic short vowels and shadda', (t) => {
|
||||
setLocale('ar');
|
||||
t.after(() => setLocale('en'));
|
||||
const ui = createTestVoiceUi();
|
||||
let draft = '';
|
||||
const prefs = bindChatPreferences({ ui, getDraft: () => draft });
|
||||
t.after(() => prefs.destroy());
|
||||
const suggested = (text) => {
|
||||
draft = text;
|
||||
prefs.render();
|
||||
return ui.state.chat.suggestions.flatMap((group) => group.items);
|
||||
};
|
||||
// The quick command is written "تتبّع", with a shadda.
|
||||
assert.deepEqual(suggested('تتبع'), ['اعرض تتبّع الرحلات المباشر']);
|
||||
prefs.remember('انتقل إلى طوكيو');
|
||||
assert.deepEqual(suggested('طُوكيو'), ['انتقل إلى طوكيو']);
|
||||
});
|
||||
Reference in new issue
Block a user