Skip to content

Commit dbb78b4

Browse files
committed
protect against a beautiful future in which javascript handles unicode sensibly
We don't need to count surrogate pairs if js stops using them
1 parent 8b14a8d commit dbb78b4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

notebook/static/base/js/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,12 @@ define([
10531053
return js_idx;
10541054
}
10551055

1056+
if ('𝐚'.length === 1) {
1057+
// If javascript fixes string indices of non-BMP characters,
1058+
// don't keep shifting offsets to compensate for surrogate pairs
1059+
char_idx_to_js_idx = js_idx_to_char_idx = function (idx, text) { return idx; };
1060+
}
1061+
10561062
// Test if a drag'n'drop event contains a file (as opposed to an HTML
10571063
// element/text from the document)
10581064
var dnd_contain_file = function(event) {

0 commit comments

Comments
 (0)