mirror of https://github.com/zulip/zulip.git
eslint: Fix unicorn/prefer-code-point.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
2e1a8ff632
commit
951b81e2bd
|
@ -832,7 +832,7 @@ test("initialize", ({override, mock_template}) => {
|
|||
// Adds a `no break-space` at the end. This should fail
|
||||
// if there wasn't any logic replacing `no break-space`
|
||||
// with normal space.
|
||||
query = "cordelia, lear's" + String.fromCharCode(160);
|
||||
query = "cordelia, lear's\u00A0";
|
||||
assert.equal(matcher(query, cordelia), true);
|
||||
assert.equal(matcher(query, othello), false);
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ run_test("mappings", () => {
|
|||
|
||||
function process(s) {
|
||||
const e = {
|
||||
which: s.charCodeAt(0),
|
||||
which: s.codePointAt(0),
|
||||
};
|
||||
try {
|
||||
return hotkey.process_keypress(e);
|
||||
|
|
|
@ -540,7 +540,7 @@ function process_keypress(e) {
|
|||
new_query = old_query.slice(0, -1);
|
||||
} else {
|
||||
// Handles any printable character.
|
||||
const key_str = String.fromCharCode(e.which);
|
||||
const key_str = String.fromCodePoint(e.which);
|
||||
new_query = old_query + key_str;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ export function set_up(input, pills, opts) {
|
|||
},
|
||||
matcher(item) {
|
||||
let query = this.query.toLowerCase();
|
||||
query = query.replace(/\u00A0/g, String.fromCharCode(32));
|
||||
query = query.replace(/\u00A0/g, " ");
|
||||
|
||||
if (include_streams(query)) {
|
||||
query = query.trim().slice(1);
|
||||
|
|
|
@ -109,27 +109,8 @@ function get_bidi_class(ch) {
|
|||
*/
|
||||
export function get_direction(str) {
|
||||
let isolations = 0;
|
||||
for (let i = 0; i < str.length; i += 1) {
|
||||
// Extracting high and low surrogates and putting them together.
|
||||
// See https://en.wikipedia.org/wiki/UTF-16#Description or section 3 of https://tools.ietf.org/html/rfc2781.
|
||||
let ch = str.charCodeAt(i);
|
||||
if (ch >= 0xd800 && ch < 0xdc00) {
|
||||
// 0xd800 <= ch < 0xdc00
|
||||
// ch is inside high surrogate range.
|
||||
// If it made a surrogate pair with the next character, put them together.
|
||||
// Otherwise, ignore the encoding error and leave it as it is.
|
||||
const ch2 = i + 1 < str.length ? str.charCodeAt(i + 1) : 0;
|
||||
if (ch2 >= 0xdc00 && ch2 < 0xe000) {
|
||||
// 0xdc00 <= ch2 < 0xe000
|
||||
// ch = ch & 0x3ff;
|
||||
ch -= 0xd800;
|
||||
// ch = 0x10000 | (ch << 10) | (ch2 & 0x3ff);
|
||||
ch = 0x10000 + ch * 0x400 + (ch2 - 0xdc00);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
const bidi_class = get_bidi_class(ch);
|
||||
for (const ch of str) {
|
||||
const bidi_class = get_bidi_class(ch.codePointAt(0));
|
||||
switch (bidi_class) {
|
||||
case "I":
|
||||
// LRI, RLI, FSI
|
||||
|
|
|
@ -87,7 +87,7 @@ function clean_query(query) {
|
|||
// contenteditable widget such as the composebox PM section, the
|
||||
// space at the end was a `no break-space (U+00A0)` instead of
|
||||
// `space (U+0020)`, which lead to no matches in those cases.
|
||||
query = query.replace(/\u00A0/g, String.fromCharCode(32));
|
||||
query = query.replace(/\u00A0/g, " ");
|
||||
|
||||
return query;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue