@lvce-editor/editor-worker 19.77.2 → 19.77.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/diff-sdk.d.ts +1 -0
- package/dist/diff-sdk.js +1846 -384
- package/dist/editorWorkerMain.js +1959 -463
- package/dist/settings.json +8 -0
- package/package.json +1 -1
package/dist/diff-sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtensionManagementWorker, SyntaxHighlightingWorker, TextMeasurementWorker, get as get$
|
|
1
|
+
import { ExtensionManagementWorker, SyntaxHighlightingWorker, TextMeasurementWorker, get as get$b, RendererWorker, ErrorWorker, CacheWorker, createLazyRpc, RpcId, OpenerWorker, DialogWorker, DragAndDropWorker, set as set$c, remove as remove$9 } from '@lvce-editor/rpc-registry';
|
|
2
2
|
|
|
3
3
|
const Text$1 = 12;
|
|
4
4
|
const Reference = 100;
|
|
@@ -448,19 +448,19 @@ const {
|
|
|
448
448
|
wrapCommand: wrapCommand$2,
|
|
449
449
|
wrapGetter
|
|
450
450
|
} = editorStates;
|
|
451
|
-
const get$
|
|
451
|
+
const get$a = id => {
|
|
452
452
|
return editorStates.get(id);
|
|
453
453
|
};
|
|
454
454
|
const getKeys$2 = () => {
|
|
455
455
|
const keys = editorStates.getKeys();
|
|
456
456
|
return keys.map(String);
|
|
457
457
|
};
|
|
458
|
-
const set$
|
|
458
|
+
const set$b = (id, oldEditor, newEditor) => {
|
|
459
459
|
editorStates.set(id, oldEditor, newEditor);
|
|
460
460
|
};
|
|
461
461
|
|
|
462
462
|
const getEditor$1 = editorUid => {
|
|
463
|
-
const instance = get$
|
|
463
|
+
const instance = get$a(editorUid);
|
|
464
464
|
if (!instance) {
|
|
465
465
|
throw new Error(`editor ${editorUid} not found`);
|
|
466
466
|
}
|
|
@@ -506,15 +506,15 @@ const ToggleBlockComment$1 = 'toggleBlockComment';
|
|
|
506
506
|
const Unknown$2 = 'unknown';
|
|
507
507
|
|
|
508
508
|
const map$1 = Object.create(null);
|
|
509
|
-
const set$
|
|
509
|
+
const set$a = (id, widget) => {
|
|
510
510
|
map$1[id] = widget;
|
|
511
511
|
};
|
|
512
|
-
const get$
|
|
512
|
+
const get$9 = id => {
|
|
513
513
|
return map$1[id];
|
|
514
514
|
};
|
|
515
515
|
|
|
516
516
|
const getModule = id => {
|
|
517
|
-
return get$
|
|
517
|
+
return get$9(id);
|
|
518
518
|
};
|
|
519
519
|
|
|
520
520
|
const applyWidgetChange = async (editor, widget, changes) => {
|
|
@@ -904,6 +904,1196 @@ const findRange = (lines, rowIndex) => {
|
|
|
904
904
|
return ranges.filter(range => range.start <= rowIndex && rowIndex <= range.end).toSorted((a, b) => a.end - a.start - (b.end - b.start))[0];
|
|
905
905
|
};
|
|
906
906
|
|
|
907
|
+
function bidiFactory$1() {
|
|
908
|
+
var bidi = (function (exports) {
|
|
909
|
+
|
|
910
|
+
// Bidi character types data, auto generated
|
|
911
|
+
var DATA = {
|
|
912
|
+
"R": "13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",
|
|
913
|
+
"EN": "1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",
|
|
914
|
+
"ES": "17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",
|
|
915
|
+
"ET": "z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",
|
|
916
|
+
"AN": "16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",
|
|
917
|
+
"CS": "18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",
|
|
918
|
+
"B": "a,3,f+2,2v,690",
|
|
919
|
+
"S": "9,2,k",
|
|
920
|
+
"WS": "c,k,4f4,1vk+a,u,1j,335",
|
|
921
|
+
"ON": "x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",
|
|
922
|
+
"BN": "0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",
|
|
923
|
+
"NSM": "lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",
|
|
924
|
+
"AL": "16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",
|
|
925
|
+
"LRO": "6ct",
|
|
926
|
+
"RLO": "6cu",
|
|
927
|
+
"LRE": "6cq",
|
|
928
|
+
"RLE": "6cr",
|
|
929
|
+
"PDF": "6cs",
|
|
930
|
+
"LRI": "6ee",
|
|
931
|
+
"RLI": "6ef",
|
|
932
|
+
"FSI": "6eg",
|
|
933
|
+
"PDI": "6eh"
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
var TYPES = {};
|
|
937
|
+
var TYPES_TO_NAMES = {};
|
|
938
|
+
TYPES.L = 1; //L is the default
|
|
939
|
+
TYPES_TO_NAMES[1] = 'L';
|
|
940
|
+
Object.keys(DATA).forEach(function (type, i) {
|
|
941
|
+
TYPES[type] = 1 << (i + 1);
|
|
942
|
+
TYPES_TO_NAMES[TYPES[type]] = type;
|
|
943
|
+
});
|
|
944
|
+
Object.freeze(TYPES);
|
|
945
|
+
|
|
946
|
+
var ISOLATE_INIT_TYPES = TYPES.LRI | TYPES.RLI | TYPES.FSI;
|
|
947
|
+
var STRONG_TYPES = TYPES.L | TYPES.R | TYPES.AL;
|
|
948
|
+
var NEUTRAL_ISOLATE_TYPES = TYPES.B | TYPES.S | TYPES.WS | TYPES.ON | TYPES.FSI | TYPES.LRI | TYPES.RLI | TYPES.PDI;
|
|
949
|
+
var BN_LIKE_TYPES = TYPES.BN | TYPES.RLE | TYPES.LRE | TYPES.RLO | TYPES.LRO | TYPES.PDF;
|
|
950
|
+
var TRAILING_TYPES = TYPES.S | TYPES.WS | TYPES.B | ISOLATE_INIT_TYPES | TYPES.PDI | BN_LIKE_TYPES;
|
|
951
|
+
|
|
952
|
+
var map = null;
|
|
953
|
+
|
|
954
|
+
function parseData () {
|
|
955
|
+
if (!map) {
|
|
956
|
+
//const start = performance.now()
|
|
957
|
+
map = new Map();
|
|
958
|
+
var start = 0;
|
|
959
|
+
for (var type in DATA) {
|
|
960
|
+
if (DATA.hasOwnProperty(type)) {
|
|
961
|
+
var segments = DATA[type];
|
|
962
|
+
var temp = '';
|
|
963
|
+
var end = (void 0);
|
|
964
|
+
var state = false;
|
|
965
|
+
var lastCode = 0;
|
|
966
|
+
for (var i = 0; i <= segments.length + 1; i += 1) {
|
|
967
|
+
var char = segments[i];
|
|
968
|
+
if (char !== ',' && i !== segments.length) {
|
|
969
|
+
if (char === '+') {
|
|
970
|
+
state = true;
|
|
971
|
+
lastCode = start = lastCode + parseInt(temp, 36);
|
|
972
|
+
temp = '';
|
|
973
|
+
} else {
|
|
974
|
+
temp += char;
|
|
975
|
+
}
|
|
976
|
+
} else {
|
|
977
|
+
if (!state) {
|
|
978
|
+
lastCode = start = lastCode + parseInt(temp, 36);
|
|
979
|
+
end = start;
|
|
980
|
+
} else {
|
|
981
|
+
end = start + parseInt(temp, 36);
|
|
982
|
+
}
|
|
983
|
+
state = false;
|
|
984
|
+
temp = '';
|
|
985
|
+
lastCode = end;
|
|
986
|
+
for (var j = start; j < end + 1; j += 1) {
|
|
987
|
+
map.set(j, TYPES[type]);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
//console.log(`char types parsed in ${performance.now() - start}ms`)
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* @param {string} char
|
|
999
|
+
* @return {number}
|
|
1000
|
+
*/
|
|
1001
|
+
function getBidiCharType (char) {
|
|
1002
|
+
parseData();
|
|
1003
|
+
return map.get(char.codePointAt(0)) || TYPES.L
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Get Bidi Character Type Name
|
|
1008
|
+
* @param {string} char
|
|
1009
|
+
* @returns { "L" | "R" | "EN" | "ES" | "ET" | "AN" | "CS" | "B" | "S" | "WS" | "ON" | "BN" | "NSM" | "AL" | "LRO" | "RLO" | "LRE" | "RLE" | "PDF" | "LRI" | "RLI" | "FSI" | "PDI" }
|
|
1010
|
+
*/
|
|
1011
|
+
function getBidiCharTypeName(char) {
|
|
1012
|
+
return TYPES_TO_NAMES[getBidiCharType(char)]
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// Bidi bracket pairs data, auto generated
|
|
1016
|
+
var data$1 = {
|
|
1017
|
+
"pairs": "14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",
|
|
1018
|
+
"canonical": "6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Parses an string that holds encoded codepoint mappings, e.g. for bracket pairs or
|
|
1023
|
+
* mirroring characters, as encoded by scripts/generateBidiData.js. Returns an object
|
|
1024
|
+
* holding the `map`, and optionally a `reverseMap` if `includeReverse:true`.
|
|
1025
|
+
* @param {string} encodedString
|
|
1026
|
+
* @param {boolean} includeReverse - true if you want reverseMap in the output
|
|
1027
|
+
* @return {{map: Map<number, number>, reverseMap?: Map<number, number>}}
|
|
1028
|
+
*/
|
|
1029
|
+
function parseCharacterMap (encodedString, includeReverse) {
|
|
1030
|
+
var radix = 36;
|
|
1031
|
+
var lastCode = 0;
|
|
1032
|
+
var map = new Map();
|
|
1033
|
+
var reverseMap = includeReverse && new Map();
|
|
1034
|
+
var prevPair;
|
|
1035
|
+
encodedString.split(',').forEach(function visit(entry) {
|
|
1036
|
+
if (entry.indexOf('+') !== -1) {
|
|
1037
|
+
for (var i = +entry; i--;) {
|
|
1038
|
+
visit(prevPair);
|
|
1039
|
+
}
|
|
1040
|
+
} else {
|
|
1041
|
+
prevPair = entry;
|
|
1042
|
+
var ref = entry.split('>');
|
|
1043
|
+
var a = ref[0];
|
|
1044
|
+
var b = ref[1];
|
|
1045
|
+
a = String.fromCodePoint(lastCode += parseInt(a, radix));
|
|
1046
|
+
b = String.fromCodePoint(lastCode += parseInt(b, radix));
|
|
1047
|
+
map.set(a, b);
|
|
1048
|
+
includeReverse && reverseMap.set(b, a);
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
return { map: map, reverseMap: reverseMap }
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
var openToClose, closeToOpen, canonical;
|
|
1055
|
+
|
|
1056
|
+
function parse$1 () {
|
|
1057
|
+
if (!openToClose) {
|
|
1058
|
+
//const start = performance.now()
|
|
1059
|
+
var ref = parseCharacterMap(data$1.pairs, true);
|
|
1060
|
+
var map = ref.map;
|
|
1061
|
+
var reverseMap = ref.reverseMap;
|
|
1062
|
+
openToClose = map;
|
|
1063
|
+
closeToOpen = reverseMap;
|
|
1064
|
+
canonical = parseCharacterMap(data$1.canonical, false).map;
|
|
1065
|
+
//console.log(`brackets parsed in ${performance.now() - start}ms`)
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Get the opening bracket character corresponding to a given closing bracket character.
|
|
1071
|
+
* @param {string} char
|
|
1072
|
+
* @returns {string | null}
|
|
1073
|
+
*/
|
|
1074
|
+
function openingToClosingBracket (char) {
|
|
1075
|
+
parse$1();
|
|
1076
|
+
return openToClose.get(char) || null
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Get the closing bracket character corresponding to a given opening bracket character.
|
|
1081
|
+
* @param {string} char
|
|
1082
|
+
* @returns {string | null}
|
|
1083
|
+
*/
|
|
1084
|
+
function closingToOpeningBracket (char) {
|
|
1085
|
+
parse$1();
|
|
1086
|
+
return closeToOpen.get(char) || null
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Retrieves the canonical form of a bracket character.
|
|
1091
|
+
* @param {string} char
|
|
1092
|
+
* @returns {string | null}
|
|
1093
|
+
*/
|
|
1094
|
+
function getCanonicalBracket (char) {
|
|
1095
|
+
parse$1();
|
|
1096
|
+
return canonical.get(char) || null
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// Local type aliases
|
|
1100
|
+
var TYPE_L = TYPES.L;
|
|
1101
|
+
var TYPE_R = TYPES.R;
|
|
1102
|
+
var TYPE_EN = TYPES.EN;
|
|
1103
|
+
var TYPE_ES = TYPES.ES;
|
|
1104
|
+
var TYPE_ET = TYPES.ET;
|
|
1105
|
+
var TYPE_AN = TYPES.AN;
|
|
1106
|
+
var TYPE_CS = TYPES.CS;
|
|
1107
|
+
var TYPE_B = TYPES.B;
|
|
1108
|
+
var TYPE_S = TYPES.S;
|
|
1109
|
+
var TYPE_ON = TYPES.ON;
|
|
1110
|
+
var TYPE_BN = TYPES.BN;
|
|
1111
|
+
var TYPE_NSM = TYPES.NSM;
|
|
1112
|
+
var TYPE_AL = TYPES.AL;
|
|
1113
|
+
var TYPE_LRO = TYPES.LRO;
|
|
1114
|
+
var TYPE_RLO = TYPES.RLO;
|
|
1115
|
+
var TYPE_LRE = TYPES.LRE;
|
|
1116
|
+
var TYPE_RLE = TYPES.RLE;
|
|
1117
|
+
var TYPE_PDF = TYPES.PDF;
|
|
1118
|
+
var TYPE_LRI = TYPES.LRI;
|
|
1119
|
+
var TYPE_RLI = TYPES.RLI;
|
|
1120
|
+
var TYPE_FSI = TYPES.FSI;
|
|
1121
|
+
var TYPE_PDI = TYPES.PDI;
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* @typedef {object} GetEmbeddingLevelsResult
|
|
1125
|
+
* @property {{start: number, end: number, level: number}[]} paragraphs
|
|
1126
|
+
* @property {Uint8Array} levels
|
|
1127
|
+
*/
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* This function applies the Bidirectional Algorithm to a string, returning the resolved embedding levels
|
|
1131
|
+
* in a single Uint8Array plus a list of objects holding each paragraph's start and end indices and resolved
|
|
1132
|
+
* base embedding level.
|
|
1133
|
+
*
|
|
1134
|
+
* @param {string} string - The input string
|
|
1135
|
+
* @param {"ltr"|"rtl"|"auto"} [baseDirection] - Use "ltr" or "rtl" to force a base paragraph direction,
|
|
1136
|
+
* otherwise a direction will be chosen automatically from each paragraph's contents.
|
|
1137
|
+
* @return {GetEmbeddingLevelsResult}
|
|
1138
|
+
*/
|
|
1139
|
+
function getEmbeddingLevels (string, baseDirection) {
|
|
1140
|
+
var MAX_DEPTH = 125;
|
|
1141
|
+
|
|
1142
|
+
// Start by mapping all characters to their unicode type, as a bitmask integer
|
|
1143
|
+
var charTypes = new Uint32Array(string.length);
|
|
1144
|
+
for (var i = 0; i < string.length; i++) {
|
|
1145
|
+
charTypes[i] = getBidiCharType(string[i]);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
var charTypeCounts = new Map(); //will be cleared at start of each paragraph
|
|
1149
|
+
function changeCharType(i, type) {
|
|
1150
|
+
var oldType = charTypes[i];
|
|
1151
|
+
charTypes[i] = type;
|
|
1152
|
+
charTypeCounts.set(oldType, charTypeCounts.get(oldType) - 1);
|
|
1153
|
+
if (oldType & NEUTRAL_ISOLATE_TYPES) {
|
|
1154
|
+
charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) - 1);
|
|
1155
|
+
}
|
|
1156
|
+
charTypeCounts.set(type, (charTypeCounts.get(type) || 0) + 1);
|
|
1157
|
+
if (type & NEUTRAL_ISOLATE_TYPES) {
|
|
1158
|
+
charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) || 0) + 1);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
var embedLevels = new Uint8Array(string.length);
|
|
1163
|
+
var isolationPairs = new Map(); //init->pdi and pdi->init
|
|
1164
|
+
|
|
1165
|
+
// === 3.3.1 The Paragraph Level ===
|
|
1166
|
+
// 3.3.1 P1: Split the text into paragraphs
|
|
1167
|
+
var paragraphs = []; // [{start, end, level}, ...]
|
|
1168
|
+
var paragraph = null;
|
|
1169
|
+
for (var i$1 = 0; i$1 < string.length; i$1++) {
|
|
1170
|
+
if (!paragraph) {
|
|
1171
|
+
paragraphs.push(paragraph = {
|
|
1172
|
+
start: i$1,
|
|
1173
|
+
end: string.length - 1,
|
|
1174
|
+
// 3.3.1 P2-P3: Determine the paragraph level
|
|
1175
|
+
level: baseDirection === 'rtl' ? 1 : baseDirection === 'ltr' ? 0 : determineAutoEmbedLevel(i$1, false)
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
if (charTypes[i$1] & TYPE_B) {
|
|
1179
|
+
paragraph.end = i$1;
|
|
1180
|
+
paragraph = null;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
var FORMATTING_TYPES = TYPE_RLE | TYPE_LRE | TYPE_RLO | TYPE_LRO | ISOLATE_INIT_TYPES | TYPE_PDI | TYPE_PDF | TYPE_B;
|
|
1185
|
+
var nextEven = function (n) { return n + ((n & 1) ? 1 : 2); };
|
|
1186
|
+
var nextOdd = function (n) { return n + ((n & 1) ? 2 : 1); };
|
|
1187
|
+
|
|
1188
|
+
// Everything from here on will operate per paragraph.
|
|
1189
|
+
for (var paraIdx = 0; paraIdx < paragraphs.length; paraIdx++) {
|
|
1190
|
+
paragraph = paragraphs[paraIdx];
|
|
1191
|
+
var statusStack = [{
|
|
1192
|
+
_level: paragraph.level,
|
|
1193
|
+
_override: 0, //0=neutral, 1=L, 2=R
|
|
1194
|
+
_isolate: 0 //bool
|
|
1195
|
+
}];
|
|
1196
|
+
var stackTop = (void 0);
|
|
1197
|
+
var overflowIsolateCount = 0;
|
|
1198
|
+
var overflowEmbeddingCount = 0;
|
|
1199
|
+
var validIsolateCount = 0;
|
|
1200
|
+
charTypeCounts.clear();
|
|
1201
|
+
|
|
1202
|
+
// === 3.3.2 Explicit Levels and Directions ===
|
|
1203
|
+
for (var i$2 = paragraph.start; i$2 <= paragraph.end; i$2++) {
|
|
1204
|
+
var charType = charTypes[i$2];
|
|
1205
|
+
stackTop = statusStack[statusStack.length - 1];
|
|
1206
|
+
|
|
1207
|
+
// Set initial counts
|
|
1208
|
+
charTypeCounts.set(charType, (charTypeCounts.get(charType) || 0) + 1);
|
|
1209
|
+
if (charType & NEUTRAL_ISOLATE_TYPES) {
|
|
1210
|
+
charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) || 0) + 1);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
// Explicit Embeddings: 3.3.2 X2 - X3
|
|
1214
|
+
if (charType & FORMATTING_TYPES) { //prefilter all formatters
|
|
1215
|
+
if (charType & (TYPE_RLE | TYPE_LRE)) {
|
|
1216
|
+
embedLevels[i$2] = stackTop._level; // 5.2
|
|
1217
|
+
var level = (charType === TYPE_RLE ? nextOdd : nextEven)(stackTop._level);
|
|
1218
|
+
if (level <= MAX_DEPTH && !overflowIsolateCount && !overflowEmbeddingCount) {
|
|
1219
|
+
statusStack.push({
|
|
1220
|
+
_level: level,
|
|
1221
|
+
_override: 0,
|
|
1222
|
+
_isolate: 0
|
|
1223
|
+
});
|
|
1224
|
+
} else if (!overflowIsolateCount) {
|
|
1225
|
+
overflowEmbeddingCount++;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// Explicit Overrides: 3.3.2 X4 - X5
|
|
1230
|
+
else if (charType & (TYPE_RLO | TYPE_LRO)) {
|
|
1231
|
+
embedLevels[i$2] = stackTop._level; // 5.2
|
|
1232
|
+
var level$1 = (charType === TYPE_RLO ? nextOdd : nextEven)(stackTop._level);
|
|
1233
|
+
if (level$1 <= MAX_DEPTH && !overflowIsolateCount && !overflowEmbeddingCount) {
|
|
1234
|
+
statusStack.push({
|
|
1235
|
+
_level: level$1,
|
|
1236
|
+
_override: (charType & TYPE_RLO) ? TYPE_R : TYPE_L,
|
|
1237
|
+
_isolate: 0
|
|
1238
|
+
});
|
|
1239
|
+
} else if (!overflowIsolateCount) {
|
|
1240
|
+
overflowEmbeddingCount++;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// Isolates: 3.3.2 X5a - X5c
|
|
1245
|
+
else if (charType & ISOLATE_INIT_TYPES) {
|
|
1246
|
+
// X5c - FSI becomes either RLI or LRI
|
|
1247
|
+
if (charType & TYPE_FSI) {
|
|
1248
|
+
charType = determineAutoEmbedLevel(i$2 + 1, true) === 1 ? TYPE_RLI : TYPE_LRI;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
embedLevels[i$2] = stackTop._level;
|
|
1252
|
+
if (stackTop._override) {
|
|
1253
|
+
changeCharType(i$2, stackTop._override);
|
|
1254
|
+
}
|
|
1255
|
+
var level$2 = (charType === TYPE_RLI ? nextOdd : nextEven)(stackTop._level);
|
|
1256
|
+
if (level$2 <= MAX_DEPTH && overflowIsolateCount === 0 && overflowEmbeddingCount === 0) {
|
|
1257
|
+
validIsolateCount++;
|
|
1258
|
+
statusStack.push({
|
|
1259
|
+
_level: level$2,
|
|
1260
|
+
_override: 0,
|
|
1261
|
+
_isolate: 1,
|
|
1262
|
+
_isolInitIndex: i$2
|
|
1263
|
+
});
|
|
1264
|
+
} else {
|
|
1265
|
+
overflowIsolateCount++;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// Terminating Isolates: 3.3.2 X6a
|
|
1270
|
+
else if (charType & TYPE_PDI) {
|
|
1271
|
+
if (overflowIsolateCount > 0) {
|
|
1272
|
+
overflowIsolateCount--;
|
|
1273
|
+
} else if (validIsolateCount > 0) {
|
|
1274
|
+
overflowEmbeddingCount = 0;
|
|
1275
|
+
while (!statusStack[statusStack.length - 1]._isolate) {
|
|
1276
|
+
statusStack.pop();
|
|
1277
|
+
}
|
|
1278
|
+
// Add to isolation pairs bidirectional mapping:
|
|
1279
|
+
var isolInitIndex = statusStack[statusStack.length - 1]._isolInitIndex;
|
|
1280
|
+
if (isolInitIndex != null) {
|
|
1281
|
+
isolationPairs.set(isolInitIndex, i$2);
|
|
1282
|
+
isolationPairs.set(i$2, isolInitIndex);
|
|
1283
|
+
}
|
|
1284
|
+
statusStack.pop();
|
|
1285
|
+
validIsolateCount--;
|
|
1286
|
+
}
|
|
1287
|
+
stackTop = statusStack[statusStack.length - 1];
|
|
1288
|
+
embedLevels[i$2] = stackTop._level;
|
|
1289
|
+
if (stackTop._override) {
|
|
1290
|
+
changeCharType(i$2, stackTop._override);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
// Terminating Embeddings and Overrides: 3.3.2 X7
|
|
1296
|
+
else if (charType & TYPE_PDF) {
|
|
1297
|
+
if (overflowIsolateCount === 0) {
|
|
1298
|
+
if (overflowEmbeddingCount > 0) {
|
|
1299
|
+
overflowEmbeddingCount--;
|
|
1300
|
+
} else if (!stackTop._isolate && statusStack.length > 1) {
|
|
1301
|
+
statusStack.pop();
|
|
1302
|
+
stackTop = statusStack[statusStack.length - 1];
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
embedLevels[i$2] = stackTop._level; // 5.2
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// End of Paragraph: 3.3.2 X8
|
|
1309
|
+
else if (charType & TYPE_B) {
|
|
1310
|
+
embedLevels[i$2] = paragraph.level;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// Non-formatting characters: 3.3.2 X6
|
|
1315
|
+
else {
|
|
1316
|
+
embedLevels[i$2] = stackTop._level;
|
|
1317
|
+
// NOTE: This exclusion of BN seems to go against what section 5.2 says, but is required for test passage
|
|
1318
|
+
if (stackTop._override && charType !== TYPE_BN) {
|
|
1319
|
+
changeCharType(i$2, stackTop._override);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// === 3.3.3 Preparations for Implicit Processing ===
|
|
1325
|
+
|
|
1326
|
+
// Remove all RLE, LRE, RLO, LRO, PDF, and BN characters: 3.3.3 X9
|
|
1327
|
+
// Note: Due to section 5.2, we won't remove them, but we'll use the BN_LIKE_TYPES bitset to
|
|
1328
|
+
// easily ignore them all from here on out.
|
|
1329
|
+
|
|
1330
|
+
// 3.3.3 X10
|
|
1331
|
+
// Compute the set of isolating run sequences as specified by BD13
|
|
1332
|
+
var levelRuns = [];
|
|
1333
|
+
var currentRun = null;
|
|
1334
|
+
for (var i$3 = paragraph.start; i$3 <= paragraph.end; i$3++) {
|
|
1335
|
+
var charType$1 = charTypes[i$3];
|
|
1336
|
+
if (!(charType$1 & BN_LIKE_TYPES)) {
|
|
1337
|
+
var lvl = embedLevels[i$3];
|
|
1338
|
+
var isIsolInit = charType$1 & ISOLATE_INIT_TYPES;
|
|
1339
|
+
var isPDI = charType$1 === TYPE_PDI;
|
|
1340
|
+
if (currentRun && lvl === currentRun._level) {
|
|
1341
|
+
currentRun._end = i$3;
|
|
1342
|
+
currentRun._endsWithIsolInit = isIsolInit;
|
|
1343
|
+
} else {
|
|
1344
|
+
levelRuns.push(currentRun = {
|
|
1345
|
+
_start: i$3,
|
|
1346
|
+
_end: i$3,
|
|
1347
|
+
_level: lvl,
|
|
1348
|
+
_startsWithPDI: isPDI,
|
|
1349
|
+
_endsWithIsolInit: isIsolInit
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
var isolatingRunSeqs = []; // [{seqIndices: [], sosType: L|R, eosType: L|R}]
|
|
1355
|
+
for (var runIdx = 0; runIdx < levelRuns.length; runIdx++) {
|
|
1356
|
+
var run = levelRuns[runIdx];
|
|
1357
|
+
if (!run._startsWithPDI || (run._startsWithPDI && !isolationPairs.has(run._start))) {
|
|
1358
|
+
var seqRuns = [currentRun = run];
|
|
1359
|
+
for (var pdiIndex = (void 0); currentRun && currentRun._endsWithIsolInit && (pdiIndex = isolationPairs.get(currentRun._end)) != null;) {
|
|
1360
|
+
for (var i$4 = runIdx + 1; i$4 < levelRuns.length; i$4++) {
|
|
1361
|
+
if (levelRuns[i$4]._start === pdiIndex) {
|
|
1362
|
+
seqRuns.push(currentRun = levelRuns[i$4]);
|
|
1363
|
+
break
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
// build flat list of indices across all runs:
|
|
1368
|
+
var seqIndices = [];
|
|
1369
|
+
for (var i$5 = 0; i$5 < seqRuns.length; i$5++) {
|
|
1370
|
+
var run$1 = seqRuns[i$5];
|
|
1371
|
+
for (var j = run$1._start; j <= run$1._end; j++) {
|
|
1372
|
+
seqIndices.push(j);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
// determine the sos/eos types:
|
|
1376
|
+
var firstLevel = embedLevels[seqIndices[0]];
|
|
1377
|
+
var prevLevel = paragraph.level;
|
|
1378
|
+
for (var i$6 = seqIndices[0] - 1; i$6 >= 0; i$6--) {
|
|
1379
|
+
if (!(charTypes[i$6] & BN_LIKE_TYPES)) { //5.2
|
|
1380
|
+
prevLevel = embedLevels[i$6];
|
|
1381
|
+
break
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
var lastIndex = seqIndices[seqIndices.length - 1];
|
|
1385
|
+
var lastLevel = embedLevels[lastIndex];
|
|
1386
|
+
var nextLevel = paragraph.level;
|
|
1387
|
+
if (!(charTypes[lastIndex] & ISOLATE_INIT_TYPES)) {
|
|
1388
|
+
for (var i$7 = lastIndex + 1; i$7 <= paragraph.end; i$7++) {
|
|
1389
|
+
if (!(charTypes[i$7] & BN_LIKE_TYPES)) { //5.2
|
|
1390
|
+
nextLevel = embedLevels[i$7];
|
|
1391
|
+
break
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
isolatingRunSeqs.push({
|
|
1396
|
+
_seqIndices: seqIndices,
|
|
1397
|
+
_sosType: Math.max(prevLevel, firstLevel) % 2 ? TYPE_R : TYPE_L,
|
|
1398
|
+
_eosType: Math.max(nextLevel, lastLevel) % 2 ? TYPE_R : TYPE_L
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// The next steps are done per isolating run sequence
|
|
1404
|
+
for (var seqIdx = 0; seqIdx < isolatingRunSeqs.length; seqIdx++) {
|
|
1405
|
+
var ref = isolatingRunSeqs[seqIdx];
|
|
1406
|
+
var seqIndices$1 = ref._seqIndices;
|
|
1407
|
+
var sosType = ref._sosType;
|
|
1408
|
+
var eosType = ref._eosType;
|
|
1409
|
+
/**
|
|
1410
|
+
* All the level runs in an isolating run sequence have the same embedding level.
|
|
1411
|
+
*
|
|
1412
|
+
* DO NOT change any `embedLevels[i]` within the current scope.
|
|
1413
|
+
*/
|
|
1414
|
+
var embedDirection = ((embedLevels[seqIndices$1[0]]) & 1) ? TYPE_R : TYPE_L;
|
|
1415
|
+
|
|
1416
|
+
// === 3.3.4 Resolving Weak Types ===
|
|
1417
|
+
|
|
1418
|
+
// W1 + 5.2. Search backward from each NSM to the first character in the isolating run sequence whose
|
|
1419
|
+
// bidirectional type is not BN, and set the NSM to ON if it is an isolate initiator or PDI, and to its
|
|
1420
|
+
// type otherwise. If the NSM is the first non-BN character, change the NSM to the type of sos.
|
|
1421
|
+
if (charTypeCounts.get(TYPE_NSM)) {
|
|
1422
|
+
for (var si = 0; si < seqIndices$1.length; si++) {
|
|
1423
|
+
var i$8 = seqIndices$1[si];
|
|
1424
|
+
if (charTypes[i$8] & TYPE_NSM) {
|
|
1425
|
+
var prevType = sosType;
|
|
1426
|
+
for (var sj = si - 1; sj >= 0; sj--) {
|
|
1427
|
+
if (!(charTypes[seqIndices$1[sj]] & BN_LIKE_TYPES)) { //5.2 scan back to first non-BN
|
|
1428
|
+
prevType = charTypes[seqIndices$1[sj]];
|
|
1429
|
+
break
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
changeCharType(i$8, (prevType & (ISOLATE_INIT_TYPES | TYPE_PDI)) ? TYPE_ON : prevType);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
// W2. Search backward from each instance of a European number until the first strong type (R, L, AL, or sos)
|
|
1438
|
+
// is found. If an AL is found, change the type of the European number to Arabic number.
|
|
1439
|
+
if (charTypeCounts.get(TYPE_EN)) {
|
|
1440
|
+
for (var si$1 = 0; si$1 < seqIndices$1.length; si$1++) {
|
|
1441
|
+
var i$9 = seqIndices$1[si$1];
|
|
1442
|
+
if (charTypes[i$9] & TYPE_EN) {
|
|
1443
|
+
for (var sj$1 = si$1 - 1; sj$1 >= -1; sj$1--) {
|
|
1444
|
+
var prevCharType = sj$1 === -1 ? sosType : charTypes[seqIndices$1[sj$1]];
|
|
1445
|
+
if (prevCharType & STRONG_TYPES) {
|
|
1446
|
+
if (prevCharType === TYPE_AL) {
|
|
1447
|
+
changeCharType(i$9, TYPE_AN);
|
|
1448
|
+
}
|
|
1449
|
+
break
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// W3. Change all ALs to R
|
|
1457
|
+
if (charTypeCounts.get(TYPE_AL)) {
|
|
1458
|
+
for (var si$2 = 0; si$2 < seqIndices$1.length; si$2++) {
|
|
1459
|
+
var i$10 = seqIndices$1[si$2];
|
|
1460
|
+
if (charTypes[i$10] & TYPE_AL) {
|
|
1461
|
+
changeCharType(i$10, TYPE_R);
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// W4. A single European separator between two European numbers changes to a European number. A single common
|
|
1467
|
+
// separator between two numbers of the same type changes to that type.
|
|
1468
|
+
if (charTypeCounts.get(TYPE_ES) || charTypeCounts.get(TYPE_CS)) {
|
|
1469
|
+
for (var si$3 = 1; si$3 < seqIndices$1.length - 1; si$3++) {
|
|
1470
|
+
var i$11 = seqIndices$1[si$3];
|
|
1471
|
+
if (charTypes[i$11] & (TYPE_ES | TYPE_CS)) {
|
|
1472
|
+
var prevType$1 = 0, nextType = 0;
|
|
1473
|
+
for (var sj$2 = si$3 - 1; sj$2 >= 0; sj$2--) {
|
|
1474
|
+
prevType$1 = charTypes[seqIndices$1[sj$2]];
|
|
1475
|
+
if (!(prevType$1 & BN_LIKE_TYPES)) { //5.2
|
|
1476
|
+
break
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
for (var sj$3 = si$3 + 1; sj$3 < seqIndices$1.length; sj$3++) {
|
|
1480
|
+
nextType = charTypes[seqIndices$1[sj$3]];
|
|
1481
|
+
if (!(nextType & BN_LIKE_TYPES)) { //5.2
|
|
1482
|
+
break
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
if (prevType$1 === nextType && (charTypes[i$11] === TYPE_ES ? prevType$1 === TYPE_EN : (prevType$1 & (TYPE_EN | TYPE_AN)))) {
|
|
1486
|
+
changeCharType(i$11, prevType$1);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
// W5. A sequence of European terminators adjacent to European numbers changes to all European numbers.
|
|
1493
|
+
if (charTypeCounts.get(TYPE_EN)) {
|
|
1494
|
+
for (var si$4 = 0; si$4 < seqIndices$1.length; si$4++) {
|
|
1495
|
+
var i$12 = seqIndices$1[si$4];
|
|
1496
|
+
if (charTypes[i$12] & TYPE_EN) {
|
|
1497
|
+
for (var sj$4 = si$4 - 1; sj$4 >= 0 && (charTypes[seqIndices$1[sj$4]] & (TYPE_ET | BN_LIKE_TYPES)); sj$4--) {
|
|
1498
|
+
changeCharType(seqIndices$1[sj$4], TYPE_EN);
|
|
1499
|
+
}
|
|
1500
|
+
for (si$4++; si$4 < seqIndices$1.length && (charTypes[seqIndices$1[si$4]] & (TYPE_ET | BN_LIKE_TYPES | TYPE_EN)); si$4++) {
|
|
1501
|
+
if (charTypes[seqIndices$1[si$4]] !== TYPE_EN) {
|
|
1502
|
+
changeCharType(seqIndices$1[si$4], TYPE_EN);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
// W6. Otherwise, separators and terminators change to Other Neutral.
|
|
1510
|
+
if (charTypeCounts.get(TYPE_ET) || charTypeCounts.get(TYPE_ES) || charTypeCounts.get(TYPE_CS)) {
|
|
1511
|
+
for (var si$5 = 0; si$5 < seqIndices$1.length; si$5++) {
|
|
1512
|
+
var i$13 = seqIndices$1[si$5];
|
|
1513
|
+
if (charTypes[i$13] & (TYPE_ET | TYPE_ES | TYPE_CS)) {
|
|
1514
|
+
changeCharType(i$13, TYPE_ON);
|
|
1515
|
+
// 5.2 transform adjacent BNs too:
|
|
1516
|
+
for (var sj$5 = si$5 - 1; sj$5 >= 0 && (charTypes[seqIndices$1[sj$5]] & BN_LIKE_TYPES); sj$5--) {
|
|
1517
|
+
changeCharType(seqIndices$1[sj$5], TYPE_ON);
|
|
1518
|
+
}
|
|
1519
|
+
for (var sj$6 = si$5 + 1; sj$6 < seqIndices$1.length && (charTypes[seqIndices$1[sj$6]] & BN_LIKE_TYPES); sj$6++) {
|
|
1520
|
+
changeCharType(seqIndices$1[sj$6], TYPE_ON);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// W7. Search backward from each instance of a European number until the first strong type (R, L, or sos)
|
|
1527
|
+
// is found. If an L is found, then change the type of the European number to L.
|
|
1528
|
+
// NOTE: implemented in single forward pass for efficiency
|
|
1529
|
+
if (charTypeCounts.get(TYPE_EN)) {
|
|
1530
|
+
for (var si$6 = 0, prevStrongType = sosType; si$6 < seqIndices$1.length; si$6++) {
|
|
1531
|
+
var i$14 = seqIndices$1[si$6];
|
|
1532
|
+
var type = charTypes[i$14];
|
|
1533
|
+
if (type & TYPE_EN) {
|
|
1534
|
+
if (prevStrongType === TYPE_L) {
|
|
1535
|
+
changeCharType(i$14, TYPE_L);
|
|
1536
|
+
}
|
|
1537
|
+
} else if (type & STRONG_TYPES) {
|
|
1538
|
+
prevStrongType = type;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// === 3.3.5 Resolving Neutral and Isolate Formatting Types ===
|
|
1544
|
+
|
|
1545
|
+
if (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES)) {
|
|
1546
|
+
// N0. Process bracket pairs in an isolating run sequence sequentially in the logical order of the text
|
|
1547
|
+
// positions of the opening paired brackets using the logic given below. Within this scope, bidirectional
|
|
1548
|
+
// types EN and AN are treated as R.
|
|
1549
|
+
var R_TYPES_FOR_N_STEPS = (TYPE_R | TYPE_EN | TYPE_AN);
|
|
1550
|
+
var STRONG_TYPES_FOR_N_STEPS = R_TYPES_FOR_N_STEPS | TYPE_L;
|
|
1551
|
+
|
|
1552
|
+
// * Identify the bracket pairs in the current isolating run sequence according to BD16.
|
|
1553
|
+
var bracketPairs = [];
|
|
1554
|
+
{
|
|
1555
|
+
var openerStack = [];
|
|
1556
|
+
for (var si$7 = 0; si$7 < seqIndices$1.length; si$7++) {
|
|
1557
|
+
// NOTE: for any potential bracket character we also test that it still carries a NI
|
|
1558
|
+
// type, as that may have been changed earlier. This doesn't seem to be explicitly
|
|
1559
|
+
// called out in the spec, but is required for passage of certain tests.
|
|
1560
|
+
if (charTypes[seqIndices$1[si$7]] & NEUTRAL_ISOLATE_TYPES) {
|
|
1561
|
+
var char = string[seqIndices$1[si$7]];
|
|
1562
|
+
var oppositeBracket = (void 0);
|
|
1563
|
+
// Opening bracket
|
|
1564
|
+
if (openingToClosingBracket(char) !== null) {
|
|
1565
|
+
if (openerStack.length < 63) {
|
|
1566
|
+
openerStack.push({ char: char, seqIndex: si$7 });
|
|
1567
|
+
} else {
|
|
1568
|
+
break
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
// Closing bracket
|
|
1572
|
+
else if ((oppositeBracket = closingToOpeningBracket(char)) !== null) {
|
|
1573
|
+
for (var stackIdx = openerStack.length - 1; stackIdx >= 0; stackIdx--) {
|
|
1574
|
+
var stackChar = openerStack[stackIdx].char;
|
|
1575
|
+
if (stackChar === oppositeBracket ||
|
|
1576
|
+
stackChar === closingToOpeningBracket(getCanonicalBracket(char)) ||
|
|
1577
|
+
openingToClosingBracket(getCanonicalBracket(stackChar)) === char
|
|
1578
|
+
) {
|
|
1579
|
+
bracketPairs.push([openerStack[stackIdx].seqIndex, si$7]);
|
|
1580
|
+
openerStack.length = stackIdx; //pop the matching bracket and all following
|
|
1581
|
+
break
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
bracketPairs.sort(function (a, b) { return a[0] - b[0]; });
|
|
1588
|
+
}
|
|
1589
|
+
// * For each bracket-pair element in the list of pairs of text positions
|
|
1590
|
+
for (var pairIdx = 0; pairIdx < bracketPairs.length; pairIdx++) {
|
|
1591
|
+
var ref$1 = bracketPairs[pairIdx];
|
|
1592
|
+
var openSeqIdx = ref$1[0];
|
|
1593
|
+
var closeSeqIdx = ref$1[1];
|
|
1594
|
+
// a. Inspect the bidirectional types of the characters enclosed within the bracket pair.
|
|
1595
|
+
// b. If any strong type (either L or R) matching the embedding direction is found, set the type for both
|
|
1596
|
+
// brackets in the pair to match the embedding direction.
|
|
1597
|
+
var foundStrongType = false;
|
|
1598
|
+
var useStrongType = 0;
|
|
1599
|
+
for (var si$8 = openSeqIdx + 1; si$8 < closeSeqIdx; si$8++) {
|
|
1600
|
+
var i$15 = seqIndices$1[si$8];
|
|
1601
|
+
if (charTypes[i$15] & STRONG_TYPES_FOR_N_STEPS) {
|
|
1602
|
+
foundStrongType = true;
|
|
1603
|
+
var lr = (charTypes[i$15] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
1604
|
+
if (lr === embedDirection) {
|
|
1605
|
+
useStrongType = lr;
|
|
1606
|
+
break
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
// c. Otherwise, if there is a strong type it must be opposite the embedding direction. Therefore, test
|
|
1611
|
+
// for an established context with a preceding strong type by checking backwards before the opening paired
|
|
1612
|
+
// bracket until the first strong type (L, R, or sos) is found.
|
|
1613
|
+
// 1. If the preceding strong type is also opposite the embedding direction, context is established, so
|
|
1614
|
+
// set the type for both brackets in the pair to that direction.
|
|
1615
|
+
// 2. Otherwise set the type for both brackets in the pair to the embedding direction.
|
|
1616
|
+
if (foundStrongType && !useStrongType) {
|
|
1617
|
+
useStrongType = sosType;
|
|
1618
|
+
for (var si$9 = openSeqIdx - 1; si$9 >= 0; si$9--) {
|
|
1619
|
+
var i$16 = seqIndices$1[si$9];
|
|
1620
|
+
if (charTypes[i$16] & STRONG_TYPES_FOR_N_STEPS) {
|
|
1621
|
+
var lr$1 = (charTypes[i$16] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
1622
|
+
if (lr$1 !== embedDirection) {
|
|
1623
|
+
useStrongType = lr$1;
|
|
1624
|
+
} else {
|
|
1625
|
+
useStrongType = embedDirection;
|
|
1626
|
+
}
|
|
1627
|
+
break
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
if (useStrongType) {
|
|
1632
|
+
charTypes[seqIndices$1[openSeqIdx]] = charTypes[seqIndices$1[closeSeqIdx]] = useStrongType;
|
|
1633
|
+
// * Any number of characters that had original bidirectional character type NSM prior to the application
|
|
1634
|
+
// of W1 that immediately follow a paired bracket which changed to L or R under N0 should change to match
|
|
1635
|
+
// the type of their preceding bracket.
|
|
1636
|
+
if (useStrongType !== embedDirection) {
|
|
1637
|
+
for (var si$10 = openSeqIdx + 1; si$10 < seqIndices$1.length; si$10++) {
|
|
1638
|
+
if (!(charTypes[seqIndices$1[si$10]] & BN_LIKE_TYPES)) {
|
|
1639
|
+
if (getBidiCharType(string[seqIndices$1[si$10]]) & TYPE_NSM) {
|
|
1640
|
+
charTypes[seqIndices$1[si$10]] = useStrongType;
|
|
1641
|
+
}
|
|
1642
|
+
break
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
if (useStrongType !== embedDirection) {
|
|
1647
|
+
for (var si$11 = closeSeqIdx + 1; si$11 < seqIndices$1.length; si$11++) {
|
|
1648
|
+
if (!(charTypes[seqIndices$1[si$11]] & BN_LIKE_TYPES)) {
|
|
1649
|
+
if (getBidiCharType(string[seqIndices$1[si$11]]) & TYPE_NSM) {
|
|
1650
|
+
charTypes[seqIndices$1[si$11]] = useStrongType;
|
|
1651
|
+
}
|
|
1652
|
+
break
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
// N1. A sequence of NIs takes the direction of the surrounding strong text if the text on both sides has the
|
|
1660
|
+
// same direction.
|
|
1661
|
+
// N2. Any remaining NIs take the embedding direction.
|
|
1662
|
+
for (var si$12 = 0; si$12 < seqIndices$1.length; si$12++) {
|
|
1663
|
+
if (charTypes[seqIndices$1[si$12]] & NEUTRAL_ISOLATE_TYPES) {
|
|
1664
|
+
var niRunStart = si$12, niRunEnd = si$12;
|
|
1665
|
+
var prevType$2 = sosType; //si === 0 ? sosType : (charTypes[seqIndices[si - 1]] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L
|
|
1666
|
+
for (var si2 = si$12 - 1; si2 >= 0; si2--) {
|
|
1667
|
+
if (charTypes[seqIndices$1[si2]] & BN_LIKE_TYPES) {
|
|
1668
|
+
niRunStart = si2; //5.2 treat BNs adjacent to NIs as NIs
|
|
1669
|
+
} else {
|
|
1670
|
+
prevType$2 = (charTypes[seqIndices$1[si2]] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
1671
|
+
break
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
var nextType$1 = eosType;
|
|
1675
|
+
for (var si2$1 = si$12 + 1; si2$1 < seqIndices$1.length; si2$1++) {
|
|
1676
|
+
if (charTypes[seqIndices$1[si2$1]] & (NEUTRAL_ISOLATE_TYPES | BN_LIKE_TYPES)) {
|
|
1677
|
+
niRunEnd = si2$1;
|
|
1678
|
+
} else {
|
|
1679
|
+
nextType$1 = (charTypes[seqIndices$1[si2$1]] & R_TYPES_FOR_N_STEPS) ? TYPE_R : TYPE_L;
|
|
1680
|
+
break
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
for (var sj$7 = niRunStart; sj$7 <= niRunEnd; sj$7++) {
|
|
1684
|
+
charTypes[seqIndices$1[sj$7]] = prevType$2 === nextType$1 ? prevType$2 : embedDirection;
|
|
1685
|
+
}
|
|
1686
|
+
si$12 = niRunEnd;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
// === 3.3.6 Resolving Implicit Levels ===
|
|
1693
|
+
|
|
1694
|
+
for (var i$17 = paragraph.start; i$17 <= paragraph.end; i$17++) {
|
|
1695
|
+
var level$3 = embedLevels[i$17];
|
|
1696
|
+
var type$1 = charTypes[i$17];
|
|
1697
|
+
// I2. For all characters with an odd (right-to-left) embedding level, those of type L, EN or AN go up one level.
|
|
1698
|
+
if (level$3 & 1) {
|
|
1699
|
+
if (type$1 & (TYPE_L | TYPE_EN | TYPE_AN)) {
|
|
1700
|
+
embedLevels[i$17]++;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
// I1. For all characters with an even (left-to-right) embedding level, those of type R go up one level
|
|
1704
|
+
// and those of type AN or EN go up two levels.
|
|
1705
|
+
else {
|
|
1706
|
+
if (type$1 & TYPE_R) {
|
|
1707
|
+
embedLevels[i$17]++;
|
|
1708
|
+
} else if (type$1 & (TYPE_AN | TYPE_EN)) {
|
|
1709
|
+
embedLevels[i$17] += 2;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
// 5.2: Resolve any LRE, RLE, LRO, RLO, PDF, or BN to the level of the preceding character if there is one,
|
|
1714
|
+
// and otherwise to the base level.
|
|
1715
|
+
if (type$1 & BN_LIKE_TYPES) {
|
|
1716
|
+
embedLevels[i$17] = i$17 === 0 ? paragraph.level : embedLevels[i$17 - 1];
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
// 3.4 L1.1-4: Reset the embedding level of segment/paragraph separators, and any sequence of whitespace or
|
|
1720
|
+
// isolate formatting characters preceding them or the end of the paragraph, to the paragraph level.
|
|
1721
|
+
// NOTE: this will also need to be applied to each individual line ending after line wrapping occurs.
|
|
1722
|
+
if (i$17 === paragraph.end || getBidiCharType(string[i$17]) & (TYPE_S | TYPE_B)) {
|
|
1723
|
+
for (var j$1 = i$17; j$1 >= 0 && (getBidiCharType(string[j$1]) & TRAILING_TYPES); j$1--) {
|
|
1724
|
+
embedLevels[j$1] = paragraph.level;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// DONE! The resolved levels can then be used, after line wrapping, to flip runs of characters
|
|
1731
|
+
// according to section 3.4 Reordering Resolved Levels
|
|
1732
|
+
return {
|
|
1733
|
+
levels: embedLevels,
|
|
1734
|
+
paragraphs: paragraphs
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
function determineAutoEmbedLevel (start, isFSI) {
|
|
1738
|
+
// 3.3.1 P2 - P3
|
|
1739
|
+
for (var i = start; i < string.length; i++) {
|
|
1740
|
+
var charType = charTypes[i];
|
|
1741
|
+
if (charType & (TYPE_R | TYPE_AL)) {
|
|
1742
|
+
return 1
|
|
1743
|
+
}
|
|
1744
|
+
if ((charType & (TYPE_B | TYPE_L)) || (isFSI && charType === TYPE_PDI)) {
|
|
1745
|
+
return 0
|
|
1746
|
+
}
|
|
1747
|
+
if (charType & ISOLATE_INIT_TYPES) {
|
|
1748
|
+
var pdi = indexOfMatchingPDI(i);
|
|
1749
|
+
i = pdi === -1 ? string.length : pdi;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
return 0
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
function indexOfMatchingPDI (isolateStart) {
|
|
1756
|
+
// 3.1.2 BD9
|
|
1757
|
+
var isolationLevel = 1;
|
|
1758
|
+
for (var i = isolateStart + 1; i < string.length; i++) {
|
|
1759
|
+
var charType = charTypes[i];
|
|
1760
|
+
if (charType & TYPE_B) {
|
|
1761
|
+
break
|
|
1762
|
+
}
|
|
1763
|
+
if (charType & TYPE_PDI) {
|
|
1764
|
+
if (--isolationLevel === 0) {
|
|
1765
|
+
return i
|
|
1766
|
+
}
|
|
1767
|
+
} else if (charType & ISOLATE_INIT_TYPES) {
|
|
1768
|
+
isolationLevel++;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
return -1
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
// Bidi mirrored chars data, auto generated
|
|
1776
|
+
var data = "14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1";
|
|
1777
|
+
|
|
1778
|
+
var mirrorMap;
|
|
1779
|
+
|
|
1780
|
+
function parse () {
|
|
1781
|
+
if (!mirrorMap) {
|
|
1782
|
+
//const start = performance.now()
|
|
1783
|
+
var ref = parseCharacterMap(data, true);
|
|
1784
|
+
var map = ref.map;
|
|
1785
|
+
var reverseMap = ref.reverseMap;
|
|
1786
|
+
// Combine both maps into one
|
|
1787
|
+
reverseMap.forEach(function (value, key) {
|
|
1788
|
+
map.set(key, value);
|
|
1789
|
+
});
|
|
1790
|
+
mirrorMap = map;
|
|
1791
|
+
//console.log(`mirrored chars parsed in ${performance.now() - start}ms`)
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* Get the mirrored character for a given character, if one exists.
|
|
1797
|
+
* @param {string} char
|
|
1798
|
+
* @return {string|null}
|
|
1799
|
+
*/
|
|
1800
|
+
function getMirroredCharacter (char) {
|
|
1801
|
+
parse();
|
|
1802
|
+
return mirrorMap.get(char) || null
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* Given a string and its resolved embedding levels, build a map of indices to replacement chars
|
|
1807
|
+
* for any characters in right-to-left segments that have defined mirrored characters.
|
|
1808
|
+
* @param {string} string
|
|
1809
|
+
* @param {Uint8Array} embeddingLevels
|
|
1810
|
+
* @param {number?} [start]
|
|
1811
|
+
* @param {number?} [end]
|
|
1812
|
+
* @return {Map<number, string>}
|
|
1813
|
+
*/
|
|
1814
|
+
function getMirroredCharactersMap(string, embeddingLevels, start, end) {
|
|
1815
|
+
var strLen = string.length;
|
|
1816
|
+
start = Math.max(0, start == null ? 0 : +start);
|
|
1817
|
+
end = Math.min(strLen - 1, end == null ? strLen - 1 : +end);
|
|
1818
|
+
|
|
1819
|
+
var map = new Map();
|
|
1820
|
+
for (var i = start; i <= end; i++) {
|
|
1821
|
+
if (embeddingLevels[i] & 1) { //only odd (rtl) levels
|
|
1822
|
+
var mirror = getMirroredCharacter(string[i]);
|
|
1823
|
+
if (mirror !== null) {
|
|
1824
|
+
map.set(i, mirror);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
return map
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* Given a start and end denoting a single line within a string, and a set of precalculated
|
|
1833
|
+
* bidi embedding levels, produce a list of segments whose ordering should be flipped, in sequence.
|
|
1834
|
+
* @param {string} string - the full input string
|
|
1835
|
+
* @param {GetEmbeddingLevelsResult} embeddingLevelsResult - the result object from getEmbeddingLevels
|
|
1836
|
+
* @param {number} [start] - first character in a subset of the full string
|
|
1837
|
+
* @param {number} [end] - last character in a subset of the full string
|
|
1838
|
+
* @return {number[][]} - the list of start/end segments that should be flipped, in order.
|
|
1839
|
+
*/
|
|
1840
|
+
function getReorderSegments(string, embeddingLevelsResult, start, end) {
|
|
1841
|
+
var strLen = string.length;
|
|
1842
|
+
start = Math.max(0, start == null ? 0 : +start);
|
|
1843
|
+
end = Math.min(strLen - 1, end == null ? strLen - 1 : +end);
|
|
1844
|
+
|
|
1845
|
+
var segments = [];
|
|
1846
|
+
embeddingLevelsResult.paragraphs.forEach(function (paragraph) {
|
|
1847
|
+
var lineStart = Math.max(start, paragraph.start);
|
|
1848
|
+
var lineEnd = Math.min(end, paragraph.end);
|
|
1849
|
+
if (lineStart < lineEnd) {
|
|
1850
|
+
// Local slice for mutation
|
|
1851
|
+
var lineLevels = embeddingLevelsResult.levels.slice(lineStart, lineEnd + 1);
|
|
1852
|
+
|
|
1853
|
+
// 3.4 L1.4: Reset any sequence of whitespace characters and/or isolate formatting characters at the
|
|
1854
|
+
// end of the line to the paragraph level.
|
|
1855
|
+
for (var i = lineEnd; i >= lineStart && (getBidiCharType(string[i]) & TRAILING_TYPES); i--) {
|
|
1856
|
+
lineLevels[i] = paragraph.level;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
// L2. From the highest level found in the text to the lowest odd level on each line, including intermediate levels
|
|
1860
|
+
// not actually present in the text, reverse any contiguous sequence of characters that are at that level or higher.
|
|
1861
|
+
var maxLevel = paragraph.level;
|
|
1862
|
+
var minOddLevel = Infinity;
|
|
1863
|
+
for (var i$1 = 0; i$1 < lineLevels.length; i$1++) {
|
|
1864
|
+
var level = lineLevels[i$1];
|
|
1865
|
+
if (level > maxLevel) { maxLevel = level; }
|
|
1866
|
+
if (level < minOddLevel) { minOddLevel = level | 1; }
|
|
1867
|
+
}
|
|
1868
|
+
for (var lvl = maxLevel; lvl >= minOddLevel; lvl--) {
|
|
1869
|
+
for (var i$2 = 0; i$2 < lineLevels.length; i$2++) {
|
|
1870
|
+
if (lineLevels[i$2] >= lvl) {
|
|
1871
|
+
var segStart = i$2;
|
|
1872
|
+
while (i$2 + 1 < lineLevels.length && lineLevels[i$2 + 1] >= lvl) {
|
|
1873
|
+
i$2++;
|
|
1874
|
+
}
|
|
1875
|
+
if (i$2 > segStart) {
|
|
1876
|
+
segments.push([segStart + lineStart, i$2 + lineStart]);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
return segments
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/**
|
|
1887
|
+
* @param {string} string
|
|
1888
|
+
* @param {GetEmbeddingLevelsResult} embedLevelsResult
|
|
1889
|
+
* @param {number} [start]
|
|
1890
|
+
* @param {number} [end]
|
|
1891
|
+
* @return {string} the new string with bidi segments reordered
|
|
1892
|
+
*/
|
|
1893
|
+
function getReorderedString(string, embedLevelsResult, start, end) {
|
|
1894
|
+
var indices = getReorderedIndices(string, embedLevelsResult, start, end);
|
|
1895
|
+
var chars = [].concat( string );
|
|
1896
|
+
indices.forEach(function (charIndex, i) {
|
|
1897
|
+
chars[i] = (
|
|
1898
|
+
(embedLevelsResult.levels[charIndex] & 1) ? getMirroredCharacter(string[charIndex]) : null
|
|
1899
|
+
) || string[charIndex];
|
|
1900
|
+
});
|
|
1901
|
+
return chars.join('')
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* @param {string} string
|
|
1906
|
+
* @param {GetEmbeddingLevelsResult} embedLevelsResult
|
|
1907
|
+
* @param {number} [start]
|
|
1908
|
+
* @param {number} [end]
|
|
1909
|
+
* @return {number[]} an array with character indices in their new bidi order
|
|
1910
|
+
*/
|
|
1911
|
+
function getReorderedIndices(string, embedLevelsResult, start, end) {
|
|
1912
|
+
var segments = getReorderSegments(string, embedLevelsResult, start, end);
|
|
1913
|
+
// Fill an array with indices
|
|
1914
|
+
var indices = [];
|
|
1915
|
+
for (var i = 0; i < string.length; i++) {
|
|
1916
|
+
indices[i] = i;
|
|
1917
|
+
}
|
|
1918
|
+
// Reverse each segment in order
|
|
1919
|
+
segments.forEach(function (ref) {
|
|
1920
|
+
var start = ref[0];
|
|
1921
|
+
var end = ref[1];
|
|
1922
|
+
|
|
1923
|
+
var slice = indices.slice(start, end + 1);
|
|
1924
|
+
for (var i = slice.length; i--;) {
|
|
1925
|
+
indices[end - i] = slice[i];
|
|
1926
|
+
}
|
|
1927
|
+
});
|
|
1928
|
+
return indices
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
exports.closingToOpeningBracket = closingToOpeningBracket;
|
|
1932
|
+
exports.getBidiCharType = getBidiCharType;
|
|
1933
|
+
exports.getBidiCharTypeName = getBidiCharTypeName;
|
|
1934
|
+
exports.getCanonicalBracket = getCanonicalBracket;
|
|
1935
|
+
exports.getEmbeddingLevels = getEmbeddingLevels;
|
|
1936
|
+
exports.getMirroredCharacter = getMirroredCharacter;
|
|
1937
|
+
exports.getMirroredCharactersMap = getMirroredCharactersMap;
|
|
1938
|
+
exports.getReorderSegments = getReorderSegments;
|
|
1939
|
+
exports.getReorderedIndices = getReorderedIndices;
|
|
1940
|
+
exports.getReorderedString = getReorderedString;
|
|
1941
|
+
exports.openingToClosingBracket = openingToClosingBracket;
|
|
1942
|
+
|
|
1943
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1944
|
+
|
|
1945
|
+
return exports;
|
|
1946
|
+
|
|
1947
|
+
})({});
|
|
1948
|
+
return bidi}
|
|
1949
|
+
|
|
1950
|
+
// bidi-js ships ES module declarations for a CommonJS package; its runtime
|
|
1951
|
+
// default export is the factory in both Node and the browser bundle.
|
|
1952
|
+
const bidiFactory = bidiFactory$1;
|
|
1953
|
+
// Keep the paragraph LTR, as in source code. Individual RTL runs still shape RTL.
|
|
1954
|
+
// Do not initialize the Unicode tables or segment ASCII lines.
|
|
1955
|
+
const state$g = {};
|
|
1956
|
+
const rtlCharacters = /[\u{590}-\u{8FF}\u{200F}\u{202A}-\u{202E}\u{2066}-\u{2069}\u{FB1D}-\u{FDFF}\u{FE70}-\u{FEFF}]|\p{Script=Adlam}/u;
|
|
1957
|
+
const isBidi = (line, enabled = false) => enabled && rtlCharacters.test(line);
|
|
1958
|
+
const getRuns = line => {
|
|
1959
|
+
const bidi = state$g.bidi ??= bidiFactory();
|
|
1960
|
+
const embedding = bidi.getEmbeddingLevels(line, 'ltr');
|
|
1961
|
+
const order = bidi.getReorderedIndices(line, embedding);
|
|
1962
|
+
const runs = [];
|
|
1963
|
+
let previousIndex = -2;
|
|
1964
|
+
for (const index of order) {
|
|
1965
|
+
const previous = runs.at(-1);
|
|
1966
|
+
const level = embedding.levels[index];
|
|
1967
|
+
if (previous && previous.level === level && Math.abs(index - previousIndex) === 1) {
|
|
1968
|
+
previous.start = Math.min(previous.start, index);
|
|
1969
|
+
previous.end = Math.max(previous.end, index + 1);
|
|
1970
|
+
} else {
|
|
1971
|
+
runs.push({
|
|
1972
|
+
end: index + 1,
|
|
1973
|
+
level,
|
|
1974
|
+
start: index
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
previousIndex = index;
|
|
1978
|
+
}
|
|
1979
|
+
return runs;
|
|
1980
|
+
};
|
|
1981
|
+
const getBoundaries = line => {
|
|
1982
|
+
const segmenter = new Intl.Segmenter(undefined, {
|
|
1983
|
+
granularity: 'grapheme'
|
|
1984
|
+
});
|
|
1985
|
+
return [...Array.from(segmenter.segment(line), ({
|
|
1986
|
+
index
|
|
1987
|
+
}) => index), line.length];
|
|
1988
|
+
};
|
|
1989
|
+
|
|
1990
|
+
// A basic editor has one caret per logical column. At an ambiguous boundary,
|
|
1991
|
+
// prefer the higher embedding level (the RTL side at ordinary LTR/RTL edges).
|
|
1992
|
+
const getCaretRun = (runs, column) => {
|
|
1993
|
+
let result = runs[0];
|
|
1994
|
+
for (const run of runs) {
|
|
1995
|
+
if (column >= run.start && column <= run.end && (column < result.start || column > result.end || run.level > result.level)) {
|
|
1996
|
+
result = run;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
return result;
|
|
2000
|
+
};
|
|
2001
|
+
const getVisualColumns = line => {
|
|
2002
|
+
const boundaries = getBoundaries(line);
|
|
2003
|
+
if (!isBidi(line, true)) {
|
|
2004
|
+
return boundaries;
|
|
2005
|
+
}
|
|
2006
|
+
const runs = getRuns(line);
|
|
2007
|
+
const logicalRuns = runs.toSorted((left, right) => left.start - right.start);
|
|
2008
|
+
const columnsByRun = new Map(runs.map(run => [run, []]));
|
|
2009
|
+
let runIndex = 0;
|
|
2010
|
+
for (const column of boundaries) {
|
|
2011
|
+
while (runIndex + 1 < logicalRuns.length && column >= logicalRuns[runIndex + 1].start) {
|
|
2012
|
+
runIndex++;
|
|
2013
|
+
}
|
|
2014
|
+
const current = logicalRuns[runIndex];
|
|
2015
|
+
const previous = logicalRuns[runIndex - 1];
|
|
2016
|
+
const owner = previous && column === current.start && previous.level > current.level ? previous : current;
|
|
2017
|
+
columnsByRun.get(owner).push(column);
|
|
2018
|
+
}
|
|
2019
|
+
const columns = [];
|
|
2020
|
+
for (const run of runs) {
|
|
2021
|
+
const part = columnsByRun.get(run);
|
|
2022
|
+
const orderedColumns = run.level % 2 ? part.toReversed() : part;
|
|
2023
|
+
for (const column of orderedColumns) {
|
|
2024
|
+
columns.push(column);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
return columns;
|
|
2028
|
+
};
|
|
2029
|
+
const getPosition = async (line, column, measure, runs = getRuns(line), selectedRun = getCaretRun(runs, column)) => {
|
|
2030
|
+
let x = 0;
|
|
2031
|
+
for (const run of runs) {
|
|
2032
|
+
const text = line.slice(run.start, run.end);
|
|
2033
|
+
const width = await measure(text);
|
|
2034
|
+
if (run === selectedRun) {
|
|
2035
|
+
const prefix = await measure(line.slice(run.start, column), {
|
|
2036
|
+
offset: column - run.start,
|
|
2037
|
+
rtl: run.level % 2 === 1,
|
|
2038
|
+
text
|
|
2039
|
+
});
|
|
2040
|
+
return x + (run.level % 2 ? width - prefix : prefix);
|
|
2041
|
+
}
|
|
2042
|
+
x += width;
|
|
2043
|
+
}
|
|
2044
|
+
return x;
|
|
2045
|
+
};
|
|
2046
|
+
const getColumn = async (line, x, measure) => {
|
|
2047
|
+
const columns = getVisualColumns(line);
|
|
2048
|
+
// Binary search the same canonical positions used by the caret, including
|
|
2049
|
+
// both line edges. This also keeps clicks out of combining sequences.
|
|
2050
|
+
const runs = getRuns(line);
|
|
2051
|
+
let low = 0;
|
|
2052
|
+
let high = columns.length - 1;
|
|
2053
|
+
while (low < high) {
|
|
2054
|
+
const middle = Math.floor((low + high) / 2);
|
|
2055
|
+
const left = await getPosition(line, columns[middle], measure, runs);
|
|
2056
|
+
const right = await getPosition(line, columns[middle + 1], measure, runs);
|
|
2057
|
+
if (x < (left + right) / 2) {
|
|
2058
|
+
high = middle;
|
|
2059
|
+
} else {
|
|
2060
|
+
low = middle + 1;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
return columns[low];
|
|
2064
|
+
};
|
|
2065
|
+
const getSelectionRanges = async (line, start, end, measure) => {
|
|
2066
|
+
const runs = getRuns(line);
|
|
2067
|
+
const ranges = [];
|
|
2068
|
+
let x = 0;
|
|
2069
|
+
for (const run of runs) {
|
|
2070
|
+
const text = line.slice(run.start, run.end);
|
|
2071
|
+
const width = await measure(text);
|
|
2072
|
+
const from = Math.max(start, run.start);
|
|
2073
|
+
const to = Math.min(end, run.end);
|
|
2074
|
+
if (from < to) {
|
|
2075
|
+
const leftPrefix = await measure(line.slice(run.start, from), {
|
|
2076
|
+
offset: from - run.start,
|
|
2077
|
+
rtl: run.level % 2 === 1,
|
|
2078
|
+
text
|
|
2079
|
+
});
|
|
2080
|
+
const rightPrefix = await measure(line.slice(run.start, to), {
|
|
2081
|
+
offset: to - run.start,
|
|
2082
|
+
rtl: run.level % 2 === 1,
|
|
2083
|
+
text
|
|
2084
|
+
});
|
|
2085
|
+
const left = run.level % 2 ? width - leftPrefix : leftPrefix;
|
|
2086
|
+
const right = run.level % 2 ? width - rightPrefix : rightPrefix;
|
|
2087
|
+
ranges.push({
|
|
2088
|
+
width: Math.abs(right - left),
|
|
2089
|
+
x: x + Math.min(left, right)
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
x += width;
|
|
2093
|
+
}
|
|
2094
|
+
return ranges;
|
|
2095
|
+
};
|
|
2096
|
+
|
|
907
2097
|
const Link$1 = 'Link';
|
|
908
2098
|
const EditorGoToDefinitionLink = 'EditorGoToDefinitionLink';
|
|
909
2099
|
const Function = 'Function';
|
|
@@ -1385,7 +2575,7 @@ const getEnabled$1 = () => {
|
|
|
1385
2575
|
};
|
|
1386
2576
|
|
|
1387
2577
|
const invoke$c = (...args) => SyntaxHighlightingWorker.invoke(...args);
|
|
1388
|
-
const set$
|
|
2578
|
+
const set$9 = (...args) => SyntaxHighlightingWorker.set(...args);
|
|
1389
2579
|
|
|
1390
2580
|
const state$d = {
|
|
1391
2581
|
pending: Object.create(null),
|
|
@@ -1395,10 +2585,10 @@ const state$d = {
|
|
|
1395
2585
|
const has = languageId => {
|
|
1396
2586
|
return Object.hasOwn(state$d.tokenizers, languageId);
|
|
1397
2587
|
};
|
|
1398
|
-
const set$
|
|
2588
|
+
const set$8 = (languageId, tokenizer) => {
|
|
1399
2589
|
state$d.tokenizers[languageId] = tokenizer;
|
|
1400
2590
|
};
|
|
1401
|
-
const get$
|
|
2591
|
+
const get$8 = languageId => {
|
|
1402
2592
|
return state$d.tokenizers[languageId];
|
|
1403
2593
|
};
|
|
1404
2594
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
@@ -1419,10 +2609,10 @@ const isPending = languageId => {
|
|
|
1419
2609
|
};
|
|
1420
2610
|
|
|
1421
2611
|
const tokenMaps = Object.create(null);
|
|
1422
|
-
const set$
|
|
2612
|
+
const set$7 = (languageId, tokenMap) => {
|
|
1423
2613
|
tokenMaps[languageId] = tokenMap;
|
|
1424
2614
|
};
|
|
1425
|
-
const get$
|
|
2615
|
+
const get$7 = languageId => {
|
|
1426
2616
|
return tokenMaps[languageId] || {};
|
|
1427
2617
|
};
|
|
1428
2618
|
|
|
@@ -1435,7 +2625,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
1435
2625
|
if (getEnabled$1()) {
|
|
1436
2626
|
// @ts-ignore
|
|
1437
2627
|
const tokenMap = await invoke$c('Tokenizer.load', languageId, tokenizePath);
|
|
1438
|
-
set$
|
|
2628
|
+
set$7(languageId, tokenMap);
|
|
1439
2629
|
return;
|
|
1440
2630
|
}
|
|
1441
2631
|
try {
|
|
@@ -1451,8 +2641,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
1451
2641
|
console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
|
|
1452
2642
|
return;
|
|
1453
2643
|
}
|
|
1454
|
-
set$
|
|
1455
|
-
set$
|
|
2644
|
+
set$7(languageId, tokenizer.TokenMap);
|
|
2645
|
+
set$8(languageId, tokenizer);
|
|
1456
2646
|
} catch (error) {
|
|
1457
2647
|
// TODO better error handling
|
|
1458
2648
|
console.error(error);
|
|
@@ -1460,7 +2650,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
1460
2650
|
};
|
|
1461
2651
|
const getTokenizer = languageId => {
|
|
1462
2652
|
if (has(languageId)) {
|
|
1463
|
-
return get$
|
|
2653
|
+
return get$8(languageId);
|
|
1464
2654
|
}
|
|
1465
2655
|
if (isPending(languageId)) {
|
|
1466
2656
|
return TokenizePlainText;
|
|
@@ -1469,7 +2659,7 @@ const getTokenizer = languageId => {
|
|
|
1469
2659
|
};
|
|
1470
2660
|
|
|
1471
2661
|
const tokenizers = [TokenizePlainText];
|
|
1472
|
-
const get$
|
|
2662
|
+
const get$6 = id => {
|
|
1473
2663
|
return tokenizers[id] || TokenizePlainText;
|
|
1474
2664
|
};
|
|
1475
2665
|
const register$1 = tokenizer => {
|
|
@@ -1559,7 +2749,7 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
|
|
|
1559
2749
|
lines,
|
|
1560
2750
|
tokenizerId
|
|
1561
2751
|
} = editor;
|
|
1562
|
-
const tokenizer = get$
|
|
2752
|
+
const tokenizer = get$6(tokenizerId);
|
|
1563
2753
|
const {
|
|
1564
2754
|
hasArrayReturn,
|
|
1565
2755
|
initialLineState,
|
|
@@ -2235,7 +3425,7 @@ const getLineInfosViewport = async (editor, tokens, embeddedResults, minLineY, m
|
|
|
2235
3425
|
languageId,
|
|
2236
3426
|
lines
|
|
2237
3427
|
} = editor;
|
|
2238
|
-
const tokenMap = get$
|
|
3428
|
+
const tokenMap = get$7(languageId);
|
|
2239
3429
|
let offset = minLineOffset;
|
|
2240
3430
|
const tabSize = editor.tabSize ?? 2;
|
|
2241
3431
|
const visibleLines = lines.slice(minLineY, maxLineY);
|
|
@@ -2246,7 +3436,7 @@ const getLineInfosViewport = async (editor, tokens, embeddedResults, minLineY, m
|
|
|
2246
3436
|
line,
|
|
2247
3437
|
segments: graphemeSegments?.[index],
|
|
2248
3438
|
tabSize,
|
|
2249
|
-
threshold: horizontalVirtualizationThreshold,
|
|
3439
|
+
threshold: isBidi(line, editor.rtl) ? Infinity : horizontalVirtualizationThreshold,
|
|
2250
3440
|
width
|
|
2251
3441
|
})), texts => measureTextWidths(texts, editor.fontWeight, editor.fontSize, editor.fontFamily, editor.letterSpacing, editor.isMonospaceFont, editor.charWidth));
|
|
2252
3442
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
@@ -2455,6 +3645,9 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
2455
3645
|
return emptyIncrementalEdits;
|
|
2456
3646
|
}
|
|
2457
3647
|
const newLine = lines[rowIndex];
|
|
3648
|
+
if (isBidi(oldLine, oldState.rtl) || isBidi(newLine, newState.rtl)) {
|
|
3649
|
+
return emptyIncrementalEdits;
|
|
3650
|
+
}
|
|
2458
3651
|
// Renderer edit offsets address full lines, so clipped rows need a fresh visible window.
|
|
2459
3652
|
const threshold = newState.horizontalVirtualizationThreshold ?? 500;
|
|
2460
3653
|
if (newState.deltaX !== 0 || oldLine.length > threshold || newLine.length > threshold) {
|
|
@@ -2772,7 +3965,7 @@ const notifyListeners = async (listenerType, method, ...params) => {
|
|
|
2772
3965
|
// Notify all listeners in parallel
|
|
2773
3966
|
const notifications = rpcIds.map(async rpcId => {
|
|
2774
3967
|
try {
|
|
2775
|
-
const rpc = get$
|
|
3968
|
+
const rpc = get$b(rpcId);
|
|
2776
3969
|
if (rpc) {
|
|
2777
3970
|
await rpc.invoke(method, ...params);
|
|
2778
3971
|
}
|
|
@@ -3247,7 +4440,7 @@ const execute$1 = (command, ...args) => {
|
|
|
3247
4440
|
|
|
3248
4441
|
const Two$1 = '2.0';
|
|
3249
4442
|
const callbacks = Object.create(null);
|
|
3250
|
-
const get$
|
|
4443
|
+
const get$5 = id => {
|
|
3251
4444
|
return callbacks[id];
|
|
3252
4445
|
};
|
|
3253
4446
|
const remove$8 = id => {
|
|
@@ -3468,7 +4661,7 @@ const warn$1 = (...args) => {
|
|
|
3468
4661
|
console.warn(...args);
|
|
3469
4662
|
};
|
|
3470
4663
|
const resolve = (id, response) => {
|
|
3471
|
-
const fn = get$
|
|
4664
|
+
const fn = get$5(id);
|
|
3472
4665
|
if (!fn) {
|
|
3473
4666
|
console.log(response);
|
|
3474
4667
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -3926,7 +5119,7 @@ const transformDiagnostics = (diagnostics, changes) => {
|
|
|
3926
5119
|
|
|
3927
5120
|
const queues$1 = {};
|
|
3928
5121
|
const enqueue = async (uid, callback) => {
|
|
3929
|
-
const instance = get$
|
|
5122
|
+
const instance = get$a(uid);
|
|
3930
5123
|
if (!instance) {
|
|
3931
5124
|
return undefined;
|
|
3932
5125
|
}
|
|
@@ -4011,7 +5204,53 @@ const getTabCount = string => {
|
|
|
4011
5204
|
return count;
|
|
4012
5205
|
};
|
|
4013
5206
|
|
|
4014
|
-
const
|
|
5207
|
+
const state$9 = {
|
|
5208
|
+
rpc: undefined
|
|
5209
|
+
};
|
|
5210
|
+
const isConnected = () => {
|
|
5211
|
+
const {
|
|
5212
|
+
rpc
|
|
5213
|
+
} = state$9;
|
|
5214
|
+
return rpc !== undefined;
|
|
5215
|
+
};
|
|
5216
|
+
const set$6 = value => {
|
|
5217
|
+
state$9.rpc = value;
|
|
5218
|
+
};
|
|
5219
|
+
const invoke$8 = (method, ...params) => {
|
|
5220
|
+
const {
|
|
5221
|
+
rpc
|
|
5222
|
+
} = state$9;
|
|
5223
|
+
if (!rpc) {
|
|
5224
|
+
throw new Error('Editor renderer process is not connected');
|
|
5225
|
+
}
|
|
5226
|
+
return rpc.invoke(method, ...params);
|
|
5227
|
+
};
|
|
5228
|
+
|
|
5229
|
+
const joiningScript = /\p{Script=Arabic}/u;
|
|
5230
|
+
const createMeasure = (fontWeight, fontSize, fontFamily, letterSpacing, tabSize, charWidth) => {
|
|
5231
|
+
// Owned by this geometry operation, so edits/font changes cannot reuse stale
|
|
5232
|
+
// shaping information and closing editors leaves no persistent text cache.
|
|
5233
|
+
const cache = new Map();
|
|
5234
|
+
const normalize = text => text.replaceAll('\t', () => ' '.repeat(tabSize));
|
|
5235
|
+
return (text, context) => {
|
|
5236
|
+
const key = JSON.stringify([text, context]);
|
|
5237
|
+
let result = cache.get(key);
|
|
5238
|
+
if (!result) {
|
|
5239
|
+
if (context && context.offset > 0 && context.offset < context.text.length && joiningScript.test(context.text)) {
|
|
5240
|
+
const normalizedOffset = normalize(context.text.slice(0, context.offset)).length;
|
|
5241
|
+
result = invoke$8('MeasureBidi.measurePrefix', normalize(context.text), normalizedOffset, fontWeight, fontSize, fontFamily, letterSpacing, context.rtl ? 'rtl' : 'ltr');
|
|
5242
|
+
} else {
|
|
5243
|
+
// The measurement worker's monospace shortcut assumes every glyph has
|
|
5244
|
+
// the ASCII width; RTL fonts and fallback glyphs need real measurement.
|
|
5245
|
+
result = measureTextWidth(normalize(text), fontWeight, fontSize, fontFamily, letterSpacing, false, charWidth);
|
|
5246
|
+
}
|
|
5247
|
+
cache.set(key, result);
|
|
5248
|
+
}
|
|
5249
|
+
return result;
|
|
5250
|
+
};
|
|
5251
|
+
};
|
|
5252
|
+
|
|
5253
|
+
const getX = async (line, column, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference = 0, measuredLineWidth, rtl = false) => {
|
|
4015
5254
|
if (!line) {
|
|
4016
5255
|
return 0;
|
|
4017
5256
|
}
|
|
@@ -4022,6 +5261,11 @@ const getX = async (line, column, fontWeight, fontSize, fontFamily, isMonospaceF
|
|
|
4022
5261
|
boolean(isMonospaceFont);
|
|
4023
5262
|
number(averageCharWidth);
|
|
4024
5263
|
number(difference);
|
|
5264
|
+
if (isBidi(line, rtl)) {
|
|
5265
|
+
const measure = createMeasure(fontWeight, fontSize, fontFamily, letterSpacing, tabSize, averageCharWidth);
|
|
5266
|
+
const x = await getPosition(line, column, measure);
|
|
5267
|
+
return Math.min(width, x - halfCursorWidth + difference);
|
|
5268
|
+
}
|
|
4025
5269
|
if (column === 0) {
|
|
4026
5270
|
return difference === 0 ? 0 : Math.min(width, difference);
|
|
4027
5271
|
}
|
|
@@ -4076,7 +5320,7 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
|
|
|
4076
5320
|
return visibleDiagnostics;
|
|
4077
5321
|
};
|
|
4078
5322
|
|
|
4079
|
-
const invoke$
|
|
5323
|
+
const invoke$7 = (...args) => RendererWorker.invoke(...args);
|
|
4080
5324
|
|
|
4081
5325
|
/**
|
|
4082
5326
|
* Merges link decorations with diagnostic decorations
|
|
@@ -4165,7 +5409,7 @@ const mergeDiagnostics = (editor, editorWithDiagnostics) => ({
|
|
|
4165
5409
|
});
|
|
4166
5410
|
const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) => {
|
|
4167
5411
|
return (await enqueue(editor.id, async () => {
|
|
4168
|
-
let latest = get$
|
|
5412
|
+
let latest = get$a(editor.id);
|
|
4169
5413
|
if (!isApplicable(latest, editor, generation)) {
|
|
4170
5414
|
return editor;
|
|
4171
5415
|
}
|
|
@@ -4178,11 +5422,11 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
|
|
|
4178
5422
|
}
|
|
4179
5423
|
let calculationState = latest.newState;
|
|
4180
5424
|
let editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
4181
|
-
latest = get$
|
|
5425
|
+
latest = get$a(editor.id);
|
|
4182
5426
|
while (isApplicable(latest, editor, generation) && !diagnosticLayoutEqual(calculationState, latest.newState)) {
|
|
4183
5427
|
calculationState = latest.newState;
|
|
4184
5428
|
editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
4185
|
-
latest = get$
|
|
5429
|
+
latest = get$a(editor.id);
|
|
4186
5430
|
}
|
|
4187
5431
|
if (!isApplicable(latest, editor, generation)) {
|
|
4188
5432
|
return editor;
|
|
@@ -4191,10 +5435,10 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
|
|
|
4191
5435
|
return latest.newState;
|
|
4192
5436
|
}
|
|
4193
5437
|
const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
|
|
4194
|
-
set$
|
|
5438
|
+
set$b(editor.id, latest.oldState, newEditor);
|
|
4195
5439
|
requestDiagnosticSnapshots.set(editor.id, diagnostics);
|
|
4196
5440
|
onAccepted?.();
|
|
4197
|
-
await invoke$
|
|
5441
|
+
await invoke$7('Editor.renderPending', newEditor.id);
|
|
4198
5442
|
pendingDiagnosticNotifications.delete(editor.id);
|
|
4199
5443
|
await notifyDiagnosticsChange(newEditor.uri, newEditor.applicationId);
|
|
4200
5444
|
return newEditor;
|
|
@@ -4222,7 +5466,7 @@ const updateDiagnostics = async (editor, timeoutMs = 0) => {
|
|
|
4222
5466
|
}
|
|
4223
5467
|
const generation = (requestGenerations.get(editor.id) ?? 0) + 1;
|
|
4224
5468
|
requestGenerations.set(editor.id, generation);
|
|
4225
|
-
requestDiagnosticSnapshots.set(editor.id, get$
|
|
5469
|
+
requestDiagnosticSnapshots.set(editor.id, get$a(editor.id)?.newState.diagnostics ?? editor.diagnostics);
|
|
4226
5470
|
const providers = new Map();
|
|
4227
5471
|
const previous = previousProviderResults.get(editor.id);
|
|
4228
5472
|
if (previous && previous.languageId === editor.languageId && previous.uri === editor.uri) {
|
|
@@ -4336,7 +5580,7 @@ const updateDiagnostics = async (editor, timeoutMs = 0) => {
|
|
|
4336
5580
|
};
|
|
4337
5581
|
try {
|
|
4338
5582
|
await Promise.all([request(), completed.promise]);
|
|
4339
|
-
const latest = get$
|
|
5583
|
+
const latest = get$a(editor.id);
|
|
4340
5584
|
if (strict && !isApplicable(latest, editor, generation)) {
|
|
4341
5585
|
throw new Error('Editor changed or closed while waiting for diagnostics');
|
|
4342
5586
|
}
|
|
@@ -4389,7 +5633,7 @@ const transformCachedDiagnostics = (editorId, changes) => {
|
|
|
4389
5633
|
};
|
|
4390
5634
|
const updateDiagnosticsAll = async () => {
|
|
4391
5635
|
for (const key of getKeys$2()) {
|
|
4392
|
-
const editor = get$
|
|
5636
|
+
const editor = get$a(Number(key))?.newState;
|
|
4393
5637
|
if (editor) {
|
|
4394
5638
|
await updateDiagnostics(editor);
|
|
4395
5639
|
}
|
|
@@ -4401,7 +5645,7 @@ const waitForDiagnostics = async (editorId, timeoutMs = 30_000) => {
|
|
|
4401
5645
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > 300_000) {
|
|
4402
5646
|
throw new Error('Diagnostics timeout must be between 1 and 300000ms');
|
|
4403
5647
|
}
|
|
4404
|
-
const editor = get$
|
|
5648
|
+
const editor = get$a(editorId)?.newState;
|
|
4405
5649
|
if (!editor || editor.initial) {
|
|
4406
5650
|
throw new Error(`Editor is not ready: ${editorId}`);
|
|
4407
5651
|
}
|
|
@@ -4432,8 +5676,9 @@ const getFontKey = ({
|
|
|
4432
5676
|
fontWeight,
|
|
4433
5677
|
isMonospaceFont,
|
|
4434
5678
|
letterSpacing,
|
|
5679
|
+
rtl,
|
|
4435
5680
|
tabSize
|
|
4436
|
-
}) => JSON.stringify([charWidth, fontFamily, fontSize, fontWeight, isMonospaceFont, letterSpacing, tabSize]);
|
|
5681
|
+
}) => JSON.stringify([charWidth, fontFamily, fontSize, fontWeight, isMonospaceFont, letterSpacing, rtl, tabSize]);
|
|
4437
5682
|
const getCachedLineWidth = (state, line) => {
|
|
4438
5683
|
const {
|
|
4439
5684
|
largeFile,
|
|
@@ -4467,6 +5712,7 @@ const updateHorizontalLayout = async state => {
|
|
|
4467
5712
|
isMonospaceFont,
|
|
4468
5713
|
letterSpacing,
|
|
4469
5714
|
lines,
|
|
5715
|
+
rtl,
|
|
4470
5716
|
tabSize,
|
|
4471
5717
|
width
|
|
4472
5718
|
} = state;
|
|
@@ -4498,8 +5744,10 @@ const updateHorizontalLayout = async state => {
|
|
|
4498
5744
|
}
|
|
4499
5745
|
}
|
|
4500
5746
|
const texts = [...textsToMeasure];
|
|
4501
|
-
const
|
|
4502
|
-
const
|
|
5747
|
+
const regularTexts = texts.filter(text => !isBidi(text, rtl));
|
|
5748
|
+
const bidiTexts = texts.filter(text => isBidi(text, rtl));
|
|
5749
|
+
const [regularWidths, bidiWidths] = await Promise.all([regularTexts.length > 0 ? measureTextWidths(regularTexts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) : [], bidiTexts.length > 0 ? measureTextWidths(bidiTexts, fontWeight, fontSize, fontFamily, letterSpacing, false, charWidth) : []]);
|
|
5750
|
+
const measuredByText = new Map([...regularTexts.map((text, index) => [text, regularWidths[index]]), ...bidiTexts.map((text, index) => [text, bidiWidths[index]])]);
|
|
4503
5751
|
for (const [line, text] of textByLine) {
|
|
4504
5752
|
widths.set(line, measuredByText.get(text));
|
|
4505
5753
|
}
|
|
@@ -4650,6 +5898,9 @@ const getVisible = async editor => {
|
|
|
4650
5898
|
visibleViewLineIndices,
|
|
4651
5899
|
width
|
|
4652
5900
|
} = editor;
|
|
5901
|
+
if (editor.rtl && actualSelectionHasBidi(editor)) {
|
|
5902
|
+
return getBidiVisible(editor);
|
|
5903
|
+
}
|
|
4653
5904
|
const averageCharWidth = charWidth;
|
|
4654
5905
|
const halfCursorWidth = cursorWidth / 2;
|
|
4655
5906
|
const actualVisibleLineIndices = visibleLineIndices || Array.from({
|
|
@@ -4769,6 +6020,76 @@ const getVisible = async editor => {
|
|
|
4769
6020
|
selectionInfos: getSelectionArray(visibleSelections)
|
|
4770
6021
|
};
|
|
4771
6022
|
};
|
|
6023
|
+
const actualSelectionHasBidi = editor => {
|
|
6024
|
+
for (let i = 0; i < editor.selections.length; i += 4) {
|
|
6025
|
+
const [startRow,, endRow] = getSelectionPairs(editor.selections, i);
|
|
6026
|
+
for (let row = Math.max(startRow, editor.minLineY); row <= Math.min(endRow, editor.maxLineY - 1); row++) {
|
|
6027
|
+
if (isBidi(editor.lines[row], true)) {
|
|
6028
|
+
return true;
|
|
6029
|
+
}
|
|
6030
|
+
}
|
|
6031
|
+
}
|
|
6032
|
+
return false;
|
|
6033
|
+
};
|
|
6034
|
+
const getBidiVisible = async editor => {
|
|
6035
|
+
const {
|
|
6036
|
+
charWidth,
|
|
6037
|
+
cursorWidth,
|
|
6038
|
+
deltaX = 0,
|
|
6039
|
+
deltaY,
|
|
6040
|
+
focused,
|
|
6041
|
+
foldingRanges = [],
|
|
6042
|
+
fontFamily,
|
|
6043
|
+
fontSize,
|
|
6044
|
+
fontWeight,
|
|
6045
|
+
itemHeight,
|
|
6046
|
+
letterSpacing,
|
|
6047
|
+
lines,
|
|
6048
|
+
maxLineY,
|
|
6049
|
+
minLineY,
|
|
6050
|
+
rowHeight,
|
|
6051
|
+
selections,
|
|
6052
|
+
tabSize,
|
|
6053
|
+
viewLineIndices
|
|
6054
|
+
} = editor;
|
|
6055
|
+
const measure = createMeasure(fontWeight, fontSize, fontFamily, letterSpacing, tabSize, charWidth);
|
|
6056
|
+
const visibleRows = editor.visibleLineIndices || Array.from({
|
|
6057
|
+
length: maxLineY - minLineY
|
|
6058
|
+
}, (_, index) => minLineY + index);
|
|
6059
|
+
const visualRow = row => viewLineIndices ? getVisualRowForDocumentRow$1(row, viewLineIndices) : getVisualRowForDocumentRow(row, foldingRanges);
|
|
6060
|
+
const top = itemHeight ? Math.floor(deltaY / itemHeight) : visualRow(minLineY);
|
|
6061
|
+
const cursors = [];
|
|
6062
|
+
const rectangles = [];
|
|
6063
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
6064
|
+
const activeRow = selections[i + 2];
|
|
6065
|
+
const activeColumn = selections[i + 3];
|
|
6066
|
+
if (visibleRows.includes(activeRow)) {
|
|
6067
|
+
const line = lines[activeRow];
|
|
6068
|
+
const x = isBidi(line, true) ? await getPosition(line, activeColumn, measure) : await measure(line.slice(0, activeColumn));
|
|
6069
|
+
cursors.push(x - deltaX - cursorWidth / 2, (visualRow(activeRow) - top) * rowHeight);
|
|
6070
|
+
}
|
|
6071
|
+
const [startRow, startColumn, endRow, endColumn] = getSelectionPairs(selections, i);
|
|
6072
|
+
const selectedRows = visibleRows.filter(row => row >= startRow && row <= endRow);
|
|
6073
|
+
for (const row of selectedRows) {
|
|
6074
|
+
const line = lines[row];
|
|
6075
|
+
const start = row === startRow ? startColumn : 0;
|
|
6076
|
+
const end = row === endRow ? endColumn : line.length;
|
|
6077
|
+
const ranges = isBidi(line, true) ? await getSelectionRanges(line, start, end, measure) : [{
|
|
6078
|
+
width: await measure(line.slice(start, end)),
|
|
6079
|
+
x: await measure(line.slice(0, start))
|
|
6080
|
+
}];
|
|
6081
|
+
for (const range of ranges) {
|
|
6082
|
+
if (range.width > 0) {
|
|
6083
|
+
rectangles.push(range.x - deltaX - cursorWidth / 2, (visualRow(row) - top) * rowHeight, range.width, rowHeight);
|
|
6084
|
+
}
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
}
|
|
6088
|
+
return {
|
|
6089
|
+
cursorInfos: getCursorArray(cursors, focused),
|
|
6090
|
+
selectionInfos: getSelectionArray(rectangles)
|
|
6091
|
+
};
|
|
6092
|
+
};
|
|
4772
6093
|
|
|
4773
6094
|
const getSelectionFromChange = change => {
|
|
4774
6095
|
const {
|
|
@@ -5000,7 +6321,7 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
5000
6321
|
...newEditor,
|
|
5001
6322
|
decorations: linkDecorations
|
|
5002
6323
|
};
|
|
5003
|
-
set$
|
|
6324
|
+
set$b(editor.uid, editor, newEditorWithDecorations);
|
|
5004
6325
|
|
|
5005
6326
|
// Notify main-area-worker about modified status change
|
|
5006
6327
|
if (!editor.modified) {
|
|
@@ -5472,7 +6793,7 @@ const getMinimapLines = async (editor, syncIncremental) => {
|
|
|
5472
6793
|
await loadTokenizers(result.tokenizersToLoad);
|
|
5473
6794
|
result = await getTokensViewport2(editor, 0, lines.length, syncIncremental);
|
|
5474
6795
|
}
|
|
5475
|
-
const tokenMap = get$
|
|
6796
|
+
const tokenMap = get$7(languageId);
|
|
5476
6797
|
return result.tokens.map((lineState, index) => getLine(lineState, result.embeddedResults, tokenMap, lines[index].length));
|
|
5477
6798
|
};
|
|
5478
6799
|
|
|
@@ -5838,23 +7159,23 @@ const getVisibleBracketMatches = async editor => {
|
|
|
5838
7159
|
};
|
|
5839
7160
|
|
|
5840
7161
|
const shouldUpdateDiagnosticData = (oldState, newState) => {
|
|
5841
|
-
return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
|
|
7162
|
+
return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
|
|
5842
7163
|
};
|
|
5843
7164
|
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
5844
|
-
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
7165
|
+
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
5845
7166
|
};
|
|
5846
7167
|
const shouldUpdateBracketMatchData = (oldState, newState) => {
|
|
5847
7168
|
if (!('bracketMatchInfos' in newState)) {
|
|
5848
7169
|
return false;
|
|
5849
7170
|
}
|
|
5850
|
-
return oldState.selections !== newState.selections || oldState.lines !== newState.lines || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
7171
|
+
return oldState.selections !== newState.selections || oldState.lines !== newState.lines || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rowHeight !== newState.rowHeight || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
5851
7172
|
};
|
|
5852
7173
|
const shouldUpdateLightBulb = (oldState, newState) => oldState.diagnostics !== newState.diagnostics || oldState.languageId !== newState.languageId || oldState.selections !== newState.selections || oldState.uri !== newState.uri;
|
|
5853
7174
|
const shouldUpdateVisibleTextData = (oldState, newState) => {
|
|
5854
7175
|
if (oldState.deltaX === newState.deltaX && (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences)) {
|
|
5855
7176
|
return false;
|
|
5856
7177
|
}
|
|
5857
|
-
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.tabSize !== newState.tabSize || oldState.horizontalVirtualizationThreshold !== newState.horizontalVirtualizationThreshold || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.letterSpacing !== newState.letterSpacing || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
|
|
7178
|
+
return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleLineIndices !== newState.visibleLineIndices || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.horizontalVirtualizationThreshold !== newState.horizontalVirtualizationThreshold || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.letterSpacing !== newState.letterSpacing || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
|
|
5858
7179
|
};
|
|
5859
7180
|
const shouldUpdateMinimapData = (oldState, newState) => {
|
|
5860
7181
|
return newState.minimapEnabled && (!oldState.minimapEnabled || oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId);
|
|
@@ -5871,7 +7192,7 @@ const mergeConflictsEqual$1 = (oldState, newState) => {
|
|
|
5871
7192
|
});
|
|
5872
7193
|
};
|
|
5873
7194
|
const updateDerivedState = async (oldState, newState, deferGutterDecorations = false) => {
|
|
5874
|
-
const horizontalState = oldState.initial || oldState.lines !== newState.lines || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.tabSize !== newState.tabSize || oldState.lineNumbers !== newState.lineNumbers || oldState.breakPoints !== newState.breakPoints || oldState.gutterDecorations !== newState.gutterDecorations || oldState.lightBulbRowIndex !== newState.lightBulbRowIndex ? await updateHorizontalLayout(newState) : newState;
|
|
7195
|
+
const horizontalState = oldState.initial || oldState.lines !== newState.lines || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.rtl !== newState.rtl || oldState.tabSize !== newState.tabSize || oldState.lineNumbers !== newState.lineNumbers || oldState.breakPoints !== newState.breakPoints || oldState.gutterDecorations !== newState.gutterDecorations || oldState.lightBulbRowIndex !== newState.lightBulbRowIndex ? await updateHorizontalLayout(newState) : newState;
|
|
5875
7196
|
const layoutState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(horizontalState, []) : horizontalState;
|
|
5876
7197
|
const nextState = mergeConflictsEqual$1(oldState, layoutState) ? layoutState : {
|
|
5877
7198
|
...layoutState,
|
|
@@ -5977,7 +7298,7 @@ const updateColorPickerValue = async (editorUid, value) => {
|
|
|
5977
7298
|
return;
|
|
5978
7299
|
}
|
|
5979
7300
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
5980
|
-
set$
|
|
7301
|
+
set$b(editorUid, editor, newEditorWithDerivedState);
|
|
5981
7302
|
};
|
|
5982
7303
|
|
|
5983
7304
|
const getColorPickerWorkerCommandMap = () => ({
|
|
@@ -6012,14 +7333,14 @@ const launchColorPickerWorker = async () => {
|
|
|
6012
7333
|
return launchWorker(name, url, undefined, getColorPickerWorkerCommandMap());
|
|
6013
7334
|
};
|
|
6014
7335
|
|
|
6015
|
-
const state$
|
|
7336
|
+
const state$8 = {};
|
|
6016
7337
|
const getOrCreate$2 = () => {
|
|
6017
|
-
if (!state$
|
|
6018
|
-
state$
|
|
7338
|
+
if (!state$8.workerPromise) {
|
|
7339
|
+
state$8.workerPromise = launchColorPickerWorker();
|
|
6019
7340
|
}
|
|
6020
|
-
return state$
|
|
7341
|
+
return state$8.workerPromise;
|
|
6021
7342
|
};
|
|
6022
|
-
const invoke$
|
|
7343
|
+
const invoke$6 = async (method, ...params) => {
|
|
6023
7344
|
const worker = await getOrCreate$2();
|
|
6024
7345
|
return await worker.invoke(method, ...params);
|
|
6025
7346
|
};
|
|
@@ -6033,10 +7354,10 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
6033
7354
|
x,
|
|
6034
7355
|
y
|
|
6035
7356
|
} = state;
|
|
6036
|
-
await invoke$
|
|
6037
|
-
await invoke$
|
|
6038
|
-
const diff = await invoke$
|
|
6039
|
-
const commands = await invoke$
|
|
7357
|
+
await invoke$6('ColorPicker.create', uid, x, y, width, height, parentUid);
|
|
7358
|
+
await invoke$6('ColorPicker.loadContent', uid, toColorPickerValue(value));
|
|
7359
|
+
const diff = await invoke$6('ColorPicker.diff2', uid);
|
|
7360
|
+
const commands = await invoke$6('ColorPicker.render2', uid, diff);
|
|
6040
7361
|
return {
|
|
6041
7362
|
...state,
|
|
6042
7363
|
commands
|
|
@@ -6190,7 +7511,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir, _langua
|
|
|
6190
7511
|
x,
|
|
6191
7512
|
y
|
|
6192
7513
|
};
|
|
6193
|
-
set$
|
|
7514
|
+
set$b(id, editor, editor);
|
|
6194
7515
|
};
|
|
6195
7516
|
|
|
6196
7517
|
const emptyEditor = {
|
|
@@ -6333,8 +7654,39 @@ const getLanguages = async (platform, assetDir) => {
|
|
|
6333
7654
|
return languages;
|
|
6334
7655
|
};
|
|
6335
7656
|
|
|
7657
|
+
const cacheName = 'lvce-editor-character-widths-v1';
|
|
7658
|
+
const character = 'a';
|
|
7659
|
+
const getKey$1 = (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
7660
|
+
return `/character-width/${encodeURIComponent(JSON.stringify([character, fontWeight, fontSize, fontFamily, letterSpacing]))}`;
|
|
7661
|
+
};
|
|
7662
|
+
const get$4 = async (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
7663
|
+
const item = await CacheWorker.getCacheStorageJsonItem(getKey$1(fontWeight, fontSize, fontFamily, letterSpacing), cacheName);
|
|
7664
|
+
const width = item?.value;
|
|
7665
|
+
if (typeof width !== 'number' || !Number.isFinite(width) || width < 0) {
|
|
7666
|
+
return undefined;
|
|
7667
|
+
}
|
|
7668
|
+
return width;
|
|
7669
|
+
};
|
|
7670
|
+
const set$5 = async (fontWeight, fontSize, fontFamily, letterSpacing, width) => {
|
|
7671
|
+
await CacheWorker.setCacheStorageJsonItem(getKey$1(fontWeight, fontSize, fontFamily, letterSpacing), width, cacheName);
|
|
7672
|
+
};
|
|
7673
|
+
|
|
6336
7674
|
const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
6337
|
-
|
|
7675
|
+
try {
|
|
7676
|
+
const cachedWidth = await get$4(fontWeight, fontSize, fontFamily, letterSpacing);
|
|
7677
|
+
if (cachedWidth !== undefined) {
|
|
7678
|
+
return cachedWidth;
|
|
7679
|
+
}
|
|
7680
|
+
} catch {
|
|
7681
|
+
// Cache failures must not prevent editor creation.
|
|
7682
|
+
}
|
|
7683
|
+
const width = await measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
7684
|
+
try {
|
|
7685
|
+
await set$5(fontWeight, fontSize, fontFamily, letterSpacing, width);
|
|
7686
|
+
} catch {
|
|
7687
|
+
// Cache failures must not prevent editor creation.
|
|
7688
|
+
}
|
|
7689
|
+
return width;
|
|
6338
7690
|
};
|
|
6339
7691
|
|
|
6340
7692
|
const normalizeLineEndings = content => {
|
|
@@ -6534,10 +7886,10 @@ const createEditor = async ({
|
|
|
6534
7886
|
focused: true,
|
|
6535
7887
|
textInfos
|
|
6536
7888
|
};
|
|
6537
|
-
set$
|
|
7889
|
+
set$b(id, emptyEditor, newEditor4);
|
|
6538
7890
|
const completionsOnTypeRaw = await get$3('editor.completionsOnType');
|
|
6539
7891
|
const completionsOnType = Boolean(completionsOnTypeRaw);
|
|
6540
|
-
set$
|
|
7892
|
+
set$b(id, emptyEditor, {
|
|
6541
7893
|
...newEditor4,
|
|
6542
7894
|
completionsOnType
|
|
6543
7895
|
});
|
|
@@ -6566,7 +7918,7 @@ const createStandaloneEditor = async ({
|
|
|
6566
7918
|
y
|
|
6567
7919
|
}) => {
|
|
6568
7920
|
createEditor2(id, uri, x, y, width, height, platform, assetDir, undefined, undefined, undefined, applicationId);
|
|
6569
|
-
const createdEditor = get$
|
|
7921
|
+
const createdEditor = get$a(id).newState;
|
|
6570
7922
|
await loadTokenizer(languageId, tokenizePath);
|
|
6571
7923
|
const tokenizerId = register$1(getTokenizer(languageId));
|
|
6572
7924
|
const configuredEditor = {
|
|
@@ -6613,7 +7965,7 @@ const createStandaloneEditor = async ({
|
|
|
6613
7965
|
selectionInfos
|
|
6614
7966
|
};
|
|
6615
7967
|
if (!createdEditor.lifecycle?.disposed) {
|
|
6616
|
-
set$
|
|
7968
|
+
set$b(id, createdEditor, finalEditor);
|
|
6617
7969
|
}
|
|
6618
7970
|
};
|
|
6619
7971
|
|
|
@@ -6676,7 +8028,7 @@ const diff = (oldState, newState) => {
|
|
|
6676
8028
|
};
|
|
6677
8029
|
|
|
6678
8030
|
const diff2 = uid => {
|
|
6679
|
-
const editor = get$
|
|
8031
|
+
const editor = get$a(uid);
|
|
6680
8032
|
if (!editor) {
|
|
6681
8033
|
return [];
|
|
6682
8034
|
}
|
|
@@ -6690,7 +8042,7 @@ const diff2 = uid => {
|
|
|
6690
8042
|
|
|
6691
8043
|
const autoSaveDelay = 1000;
|
|
6692
8044
|
const pendingSaves = new Map();
|
|
6693
|
-
const state$
|
|
8045
|
+
const state$7 = {
|
|
6694
8046
|
nextToken: 0
|
|
6695
8047
|
};
|
|
6696
8048
|
const run = async (uid, token, save) => {
|
|
@@ -6701,7 +8053,7 @@ const run = async (uid, token, save) => {
|
|
|
6701
8053
|
};
|
|
6702
8054
|
const schedule$1 = (uid, save) => {
|
|
6703
8055
|
dispose$4(uid);
|
|
6704
|
-
const token = ++state$
|
|
8056
|
+
const token = ++state$7.nextToken;
|
|
6705
8057
|
const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
|
|
6706
8058
|
pendingSaves.set(uid, {
|
|
6707
8059
|
timeout,
|
|
@@ -6734,12 +8086,12 @@ const clear$3 = editorUid => {
|
|
|
6734
8086
|
dismissals$1.delete(editorUid);
|
|
6735
8087
|
}
|
|
6736
8088
|
};
|
|
6737
|
-
const set$
|
|
8089
|
+
const set$4 = (editorUid, dismissal) => {
|
|
6738
8090
|
clear$3(editorUid);
|
|
6739
8091
|
dismissals$1.set(editorUid, dismissal);
|
|
6740
8092
|
};
|
|
6741
8093
|
|
|
6742
|
-
const state$
|
|
8094
|
+
const state$6 = {
|
|
6743
8095
|
editor: undefined,
|
|
6744
8096
|
timeout: -1,
|
|
6745
8097
|
token: 0,
|
|
@@ -6747,29 +8099,29 @@ const state$7 = {
|
|
|
6747
8099
|
y: 0
|
|
6748
8100
|
};
|
|
6749
8101
|
const get$2 = () => {
|
|
6750
|
-
return state$
|
|
8102
|
+
return state$6;
|
|
6751
8103
|
};
|
|
6752
|
-
const set$
|
|
6753
|
-
state$
|
|
6754
|
-
state$
|
|
6755
|
-
state$
|
|
6756
|
-
state$
|
|
6757
|
-
state$
|
|
8104
|
+
const set$3 = (editor, timeout, x, y, token) => {
|
|
8105
|
+
state$6.editor = editor;
|
|
8106
|
+
state$6.timeout = timeout;
|
|
8107
|
+
state$6.token = token;
|
|
8108
|
+
state$6.x = x;
|
|
8109
|
+
state$6.y = y;
|
|
6758
8110
|
};
|
|
6759
8111
|
const clear$2 = editorUid => {
|
|
6760
8112
|
const {
|
|
6761
8113
|
editor,
|
|
6762
8114
|
timeout
|
|
6763
|
-
} = state$
|
|
8115
|
+
} = state$6;
|
|
6764
8116
|
if (editorUid !== undefined && editor?.uid !== editorUid) {
|
|
6765
8117
|
return;
|
|
6766
8118
|
}
|
|
6767
8119
|
if (timeout !== -1) {
|
|
6768
8120
|
clearTimeout(timeout);
|
|
6769
8121
|
}
|
|
6770
|
-
state$
|
|
6771
|
-
state$
|
|
6772
|
-
state$
|
|
8122
|
+
state$6.editor = undefined;
|
|
8123
|
+
state$6.timeout = -1;
|
|
8124
|
+
state$6.token++;
|
|
6773
8125
|
};
|
|
6774
8126
|
|
|
6775
8127
|
const dismissals = new Map();
|
|
@@ -6781,7 +8133,7 @@ const clear$1 = editorUid => {
|
|
|
6781
8133
|
clearTimeout(dismissal.timeout);
|
|
6782
8134
|
dismissals.delete(editorUid);
|
|
6783
8135
|
};
|
|
6784
|
-
const set$
|
|
8136
|
+
const set$2 = (editorUid, dismissal) => {
|
|
6785
8137
|
clear$1(editorUid);
|
|
6786
8138
|
dismissals.set(editorUid, dismissal);
|
|
6787
8139
|
};
|
|
@@ -6823,7 +8175,7 @@ const getEditorStatus = editor => {
|
|
|
6823
8175
|
};
|
|
6824
8176
|
|
|
6825
8177
|
const sendToListener = async (rpcId, status) => {
|
|
6826
|
-
const rpc = get$
|
|
8178
|
+
const rpc = get$b(rpcId);
|
|
6827
8179
|
if (rpc) {
|
|
6828
8180
|
await send(rpcId, rpc, status);
|
|
6829
8181
|
}
|
|
@@ -6832,7 +8184,7 @@ const initializeListener = async rpcId => {
|
|
|
6832
8184
|
if (!getListeners(EditorSelection$1).includes(rpcId)) {
|
|
6833
8185
|
return;
|
|
6834
8186
|
}
|
|
6835
|
-
const editor = getKeys$2().map(uid => get$
|
|
8187
|
+
const editor = getKeys$2().map(uid => get$a(Number(uid))?.newState).find(state => {
|
|
6836
8188
|
const {
|
|
6837
8189
|
focused,
|
|
6838
8190
|
initial
|
|
@@ -6861,14 +8213,14 @@ const launchRenameWorker = async () => {
|
|
|
6861
8213
|
};
|
|
6862
8214
|
|
|
6863
8215
|
let workerPromise;
|
|
6864
|
-
const invoke$
|
|
8216
|
+
const invoke$5 = async (method, ...params) => {
|
|
6865
8217
|
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function
|
|
6866
8218
|
workerPromise ||= launchRenameWorker();
|
|
6867
8219
|
const worker = await workerPromise;
|
|
6868
8220
|
return await worker.invoke(method, ...params);
|
|
6869
8221
|
};
|
|
6870
8222
|
const dispose$3 = async () => {
|
|
6871
|
-
if (getKeys$2().some(uid => get$
|
|
8223
|
+
if (getKeys$2().some(uid => get$a(Number(uid))?.newState.widgets?.some(widget => widget.id === Rename$1))) {
|
|
6872
8224
|
return;
|
|
6873
8225
|
}
|
|
6874
8226
|
const promise = workerPromise;
|
|
@@ -6885,7 +8237,7 @@ const textAppendPaths = new Map();
|
|
|
6885
8237
|
const get$1 = uid => {
|
|
6886
8238
|
return renderedDoms.get(uid);
|
|
6887
8239
|
};
|
|
6888
|
-
const set$
|
|
8240
|
+
const set$1 = (uid, dom, paths) => {
|
|
6889
8241
|
renderedDoms.set(uid, dom);
|
|
6890
8242
|
setTextAppendPaths(uid, paths);
|
|
6891
8243
|
};
|
|
@@ -6905,14 +8257,14 @@ const dispose$2 = uid => {
|
|
|
6905
8257
|
};
|
|
6906
8258
|
|
|
6907
8259
|
const addWidget$1 = widget => {
|
|
6908
|
-
const module = get$
|
|
8260
|
+
const module = get$9(widget.id);
|
|
6909
8261
|
if (!module) {
|
|
6910
8262
|
throw new Error('unsupported widget');
|
|
6911
8263
|
}
|
|
6912
8264
|
return module.add(widget);
|
|
6913
8265
|
};
|
|
6914
8266
|
const renderWidget = widget => {
|
|
6915
|
-
const module = get$
|
|
8267
|
+
const module = get$9(widget.id);
|
|
6916
8268
|
if (!module) {
|
|
6917
8269
|
throw new Error('unsupported widget');
|
|
6918
8270
|
}
|
|
@@ -6981,7 +8333,7 @@ const renderWidgets$1 = (oldState, newState) => {
|
|
|
6981
8333
|
};
|
|
6982
8334
|
|
|
6983
8335
|
const disposeEditor = async editorUid => {
|
|
6984
|
-
const editor = get$
|
|
8336
|
+
const editor = get$a(editorUid)?.newState;
|
|
6985
8337
|
if (!editor) {
|
|
6986
8338
|
return [];
|
|
6987
8339
|
}
|
|
@@ -7009,7 +8361,7 @@ const disposeEditor = async editorUid => {
|
|
|
7009
8361
|
}
|
|
7010
8362
|
for (const widget of editor.widgets) {
|
|
7011
8363
|
if (widget.id === ColorPicker$2) {
|
|
7012
|
-
pending.push(invoke$
|
|
8364
|
+
pending.push(invoke$6('ColorPicker.dispose', widget.newState.uid));
|
|
7013
8365
|
}
|
|
7014
8366
|
}
|
|
7015
8367
|
const commands = renderWidgets$1(editor, {
|
|
@@ -7084,7 +8436,7 @@ const hydrateWidget = (editor, widgetId, uid, newState) => {
|
|
|
7084
8436
|
};
|
|
7085
8437
|
};
|
|
7086
8438
|
const getLatestEditor = (uid, fallback) => {
|
|
7087
|
-
const instance = get$
|
|
8439
|
+
const instance = get$a(uid);
|
|
7088
8440
|
return instance?.newState || fallback;
|
|
7089
8441
|
};
|
|
7090
8442
|
const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
|
|
@@ -7116,7 +8468,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7116
8468
|
};
|
|
7117
8469
|
if (fullFocus) {
|
|
7118
8470
|
// Staging changes pending state; only rendering may advance the mounted baseline.
|
|
7119
|
-
set$
|
|
8471
|
+
set$b(editor.uid, get$a(editor.uid)?.oldState || editor, stagedEditor);
|
|
7120
8472
|
}
|
|
7121
8473
|
const newState = await newStateGenerator(initialState, editor.uid);
|
|
7122
8474
|
if (!newState) {
|
|
@@ -7126,7 +8478,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7126
8478
|
if (fullFocus) {
|
|
7127
8479
|
const latestEditor = getLatestEditor(editor.uid, stagedEditor);
|
|
7128
8480
|
if (latestEditor === stagedEditor) {
|
|
7129
|
-
set$
|
|
8481
|
+
set$b(editor.uid, get$a(editor.uid)?.oldState || editor, editor);
|
|
7130
8482
|
}
|
|
7131
8483
|
return latestEditor === stagedEditor ? editor : latestEditor;
|
|
7132
8484
|
}
|
|
@@ -7147,7 +8499,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7147
8499
|
} : currentEditor;
|
|
7148
8500
|
const hydratedEditor = hydrateWidget(latestEditor, widgetId, widgetUid, latestState);
|
|
7149
8501
|
if (hydratedEditor !== latestEditor) {
|
|
7150
|
-
set$
|
|
8502
|
+
set$b(editor.uid, get$a(editor.uid)?.oldState || editor, hydratedEditor);
|
|
7151
8503
|
}
|
|
7152
8504
|
return hydratedEditor;
|
|
7153
8505
|
}
|
|
@@ -7164,7 +8516,7 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7164
8516
|
};
|
|
7165
8517
|
};
|
|
7166
8518
|
|
|
7167
|
-
const state$
|
|
8519
|
+
const state$5 = {
|
|
7168
8520
|
configured: false,
|
|
7169
8521
|
lastId: -1,
|
|
7170
8522
|
nextId: 0
|
|
@@ -7172,23 +8524,23 @@ const state$6 = {
|
|
|
7172
8524
|
const configure = (start, end) => {
|
|
7173
8525
|
const {
|
|
7174
8526
|
configured
|
|
7175
|
-
} = state$
|
|
8527
|
+
} = state$5;
|
|
7176
8528
|
if (configured) {
|
|
7177
8529
|
throw new Error('Component id range is already configured');
|
|
7178
8530
|
}
|
|
7179
8531
|
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
|
|
7180
8532
|
throw new Error('Invalid component id range');
|
|
7181
8533
|
}
|
|
7182
|
-
state$
|
|
7183
|
-
state$
|
|
7184
|
-
state$
|
|
8534
|
+
state$5.nextId = start;
|
|
8535
|
+
state$5.lastId = end;
|
|
8536
|
+
state$5.configured = true;
|
|
7185
8537
|
};
|
|
7186
8538
|
const create$8 = () => {
|
|
7187
8539
|
const {
|
|
7188
8540
|
configured,
|
|
7189
8541
|
lastId,
|
|
7190
8542
|
nextId
|
|
7191
|
-
} = state$
|
|
8543
|
+
} = state$5;
|
|
7192
8544
|
if (!configured) {
|
|
7193
8545
|
// Compatibility with renderer versions that do not assign worker id ranges.
|
|
7194
8546
|
return Math.random();
|
|
@@ -7196,7 +8548,7 @@ const create$8 = () => {
|
|
|
7196
8548
|
if (nextId > lastId) {
|
|
7197
8549
|
throw new Error('Component id range exhausted');
|
|
7198
8550
|
}
|
|
7199
|
-
return state$
|
|
8551
|
+
return state$5.nextId++;
|
|
7200
8552
|
};
|
|
7201
8553
|
|
|
7202
8554
|
const create$7 = () => {
|
|
@@ -7224,7 +8576,7 @@ const create$7 = () => {
|
|
|
7224
8576
|
};
|
|
7225
8577
|
|
|
7226
8578
|
const {
|
|
7227
|
-
invoke: invoke$
|
|
8579
|
+
invoke: invoke$4,
|
|
7228
8580
|
setFactory
|
|
7229
8581
|
} = createLazyRpc(RpcId.CompletionWorker);
|
|
7230
8582
|
|
|
@@ -7290,7 +8642,7 @@ const updateWidget = (editor, widgetId, newState) => {
|
|
|
7290
8642
|
|
|
7291
8643
|
const disposeCompletion = async uid => {
|
|
7292
8644
|
try {
|
|
7293
|
-
await invoke$
|
|
8645
|
+
await invoke$4('Completions.dispose', uid);
|
|
7294
8646
|
} catch {
|
|
7295
8647
|
// A completion worker may already have disposed this state during shutdown.
|
|
7296
8648
|
}
|
|
@@ -7305,19 +8657,19 @@ const newStateGenerator$4 = async (state, parentUid, markCreated, automatic) =>
|
|
|
7305
8657
|
} = state;
|
|
7306
8658
|
const {
|
|
7307
8659
|
newState
|
|
7308
|
-
} = get$
|
|
8660
|
+
} = get$a(parentUid);
|
|
7309
8661
|
const {
|
|
7310
8662
|
applicationId,
|
|
7311
8663
|
languageId
|
|
7312
8664
|
} = newState;
|
|
7313
|
-
await invoke$
|
|
8665
|
+
await invoke$4('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
7314
8666
|
markCreated();
|
|
7315
|
-
await invoke$
|
|
7316
|
-
if (automatic && !(await invoke$
|
|
8667
|
+
await invoke$4('Completions.loadContent', uid, automatic);
|
|
8668
|
+
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
7317
8669
|
return undefined;
|
|
7318
8670
|
}
|
|
7319
|
-
const diff = await invoke$
|
|
7320
|
-
const commands = await invoke$
|
|
8671
|
+
const diff = await invoke$4('Completions.diff2', uid);
|
|
8672
|
+
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
7321
8673
|
return {
|
|
7322
8674
|
...state,
|
|
7323
8675
|
automatic,
|
|
@@ -7330,15 +8682,15 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7330
8682
|
const {
|
|
7331
8683
|
uid
|
|
7332
8684
|
} = widget.newState;
|
|
7333
|
-
await invoke$
|
|
7334
|
-
if (!isCurrent$1(editor, get$
|
|
7335
|
-
return get$
|
|
8685
|
+
await invoke$4('Completions.loadContent', uid, automatic);
|
|
8686
|
+
if (!isCurrent$1(editor, get$a(editor.uid)?.newState)) {
|
|
8687
|
+
return get$a(editor.uid)?.newState || editor;
|
|
7336
8688
|
}
|
|
7337
|
-
if (automatic && !(await invoke$
|
|
8689
|
+
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
7338
8690
|
return closeCompletion(editor);
|
|
7339
8691
|
}
|
|
7340
|
-
const diff = await invoke$
|
|
7341
|
-
const commands = await invoke$
|
|
8692
|
+
const diff = await invoke$4('Completions.diff2', uid);
|
|
8693
|
+
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
7342
8694
|
return updateWidget(editor, Completion, {
|
|
7343
8695
|
...widget.newState,
|
|
7344
8696
|
automatic,
|
|
@@ -7364,7 +8716,7 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7364
8716
|
const fullFocus = false;
|
|
7365
8717
|
const result = await addWidgetToEditor(Completion, EditorCompletion, editor, create$7, generateState, fullFocus);
|
|
7366
8718
|
const wasAdded = (result?.widgets || []).some(widget => widget.id === Completion && widget.newState.uid === completionUid);
|
|
7367
|
-
const currentEditor = get$
|
|
8719
|
+
const currentEditor = get$a(editor.uid)?.newState;
|
|
7368
8720
|
if (created && (!wasAdded || !isCurrent$1(editor, currentEditor))) {
|
|
7369
8721
|
await disposeCompletion(completionUid);
|
|
7370
8722
|
}
|
|
@@ -8096,7 +9448,7 @@ const normalizeGuess = (line, guess, tabSize) => {
|
|
|
8096
9448
|
}
|
|
8097
9449
|
return normalizedGuess;
|
|
8098
9450
|
};
|
|
8099
|
-
const getAccurateColumnIndex = async (line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, eventX) => {
|
|
9451
|
+
const getAccurateColumnIndex = async (line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, eventX, rtl = false) => {
|
|
8100
9452
|
string(line);
|
|
8101
9453
|
number(fontWeight);
|
|
8102
9454
|
number(fontSize);
|
|
@@ -8107,6 +9459,10 @@ const getAccurateColumnIndex = async (line, fontWeight, fontSize, fontFamily, le
|
|
|
8107
9459
|
number(tabSize);
|
|
8108
9460
|
number(eventX);
|
|
8109
9461
|
// Assert.greaterZero(charWidth)
|
|
9462
|
+
if (isBidi(line, rtl)) {
|
|
9463
|
+
const measure = createMeasure(fontWeight, fontSize, fontFamily, letterSpacing, tabSize, charWidth);
|
|
9464
|
+
return getColumn(line, eventX, measure);
|
|
9465
|
+
}
|
|
8110
9466
|
const guess = guessOffset(eventX, charWidth);
|
|
8111
9467
|
const normalize = shouldNormalizeText(line);
|
|
8112
9468
|
const normalizedGuess = normalizeGuess(line, guess, tabSize);
|
|
@@ -8156,7 +9512,7 @@ const at = async (editor, eventX, eventY) => {
|
|
|
8156
9512
|
const relativeX = Math.max(0, eventX - x - gutterWidth + deltaX);
|
|
8157
9513
|
const clampedRowIndex = clamp(rowIndex, 0, lines.length - 1);
|
|
8158
9514
|
const line = lines[clampedRowIndex];
|
|
8159
|
-
const columnIndex = await getAccurateColumnIndex(line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, relativeX);
|
|
9515
|
+
const columnIndex = await getAccurateColumnIndex(line, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth, tabSize, relativeX, editor.rtl);
|
|
8160
9516
|
return {
|
|
8161
9517
|
columnIndex,
|
|
8162
9518
|
rowIndex: clampedRowIndex
|
|
@@ -8188,7 +9544,7 @@ const getCursorX = async (editor, rowIndex, columnIndex) => {
|
|
|
8188
9544
|
width,
|
|
8189
9545
|
x
|
|
8190
9546
|
} = editor;
|
|
8191
|
-
const textX = await getX(lines[rowIndex] || '', columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth);
|
|
9547
|
+
const textX = await getX(lines[rowIndex] || '', columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, 0, width, charWidth, 0, undefined, editor.rtl);
|
|
8192
9548
|
return x + gutterWidth + textX - deltaX;
|
|
8193
9549
|
};
|
|
8194
9550
|
const y = (editor, rowIndex) => {
|
|
@@ -8239,7 +9595,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
|
|
|
8239
9595
|
if (typeof editor.uid === 'number') {
|
|
8240
9596
|
const timeout = setTimeout(async () => {
|
|
8241
9597
|
clear$1(editor.uid);
|
|
8242
|
-
const latestInstance = get$
|
|
9598
|
+
const latestInstance = get$a(editor.uid);
|
|
8243
9599
|
if (!latestInstance) {
|
|
8244
9600
|
return;
|
|
8245
9601
|
}
|
|
@@ -8253,10 +9609,10 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
|
|
|
8253
9609
|
widgetRevision: next(editor.uid),
|
|
8254
9610
|
widgets: removeEditorWidget(latestEditor.widgets, Message)
|
|
8255
9611
|
};
|
|
8256
|
-
set$
|
|
9612
|
+
set$b(editor.uid, latestEditor, editorWithoutMessage);
|
|
8257
9613
|
await RendererWorker.invoke('Editor.renderPending', editor.uid);
|
|
8258
9614
|
}, editor.messageDelay ?? defaultMessageDelay);
|
|
8259
|
-
set$
|
|
9615
|
+
set$2(editor.uid, {
|
|
8260
9616
|
timeout
|
|
8261
9617
|
});
|
|
8262
9618
|
}
|
|
@@ -8452,7 +9808,7 @@ const refresh = async request => {
|
|
|
8452
9808
|
}
|
|
8453
9809
|
const gutterDecorations = await getEditorGutterDecorations(snapshot);
|
|
8454
9810
|
const changed = await enqueue(snapshot.uid, async () => {
|
|
8455
|
-
const current = get$
|
|
9811
|
+
const current = get$a(snapshot.uid)?.newState;
|
|
8456
9812
|
if (!isCurrent(current, snapshot) || current.gutterDecorations.length === gutterDecorations.length && gutterDecorations.every((item, index) => item.rowIndex === current.gutterDecorations[index].rowIndex && item.type === current.gutterDecorations[index].type)) {
|
|
8457
9813
|
return false;
|
|
8458
9814
|
}
|
|
@@ -8461,11 +9817,11 @@ const refresh = async request => {
|
|
|
8461
9817
|
gutterDecorations
|
|
8462
9818
|
});
|
|
8463
9819
|
// Derived state may await layout RPCs while an asynchronous render consumes the baseline.
|
|
8464
|
-
const latest = get$
|
|
9820
|
+
const latest = get$a(snapshot.uid);
|
|
8465
9821
|
if (!isCurrent(latest?.newState, snapshot)) {
|
|
8466
9822
|
return false;
|
|
8467
9823
|
}
|
|
8468
|
-
set$
|
|
9824
|
+
set$b(snapshot.uid, latest.oldState, next);
|
|
8469
9825
|
return true;
|
|
8470
9826
|
});
|
|
8471
9827
|
if (changed) {
|
|
@@ -8544,7 +9900,7 @@ const selectionsEqual = (left, right) => {
|
|
|
8544
9900
|
return true;
|
|
8545
9901
|
};
|
|
8546
9902
|
const saveAfterDelay = async (uid, token) => {
|
|
8547
|
-
if (!get$
|
|
9903
|
+
if (!get$a(uid)) {
|
|
8548
9904
|
consume(uid, token);
|
|
8549
9905
|
return;
|
|
8550
9906
|
}
|
|
@@ -8574,7 +9930,7 @@ const saveAfterDelay = async (uid, token) => {
|
|
|
8574
9930
|
const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true) => {
|
|
8575
9931
|
const command = async (uid, ...args) => {
|
|
8576
9932
|
return enqueue(uid, async () => {
|
|
8577
|
-
const oldInstance = get$
|
|
9933
|
+
const oldInstance = get$a(uid);
|
|
8578
9934
|
if (!oldInstance) {
|
|
8579
9935
|
return undefined;
|
|
8580
9936
|
}
|
|
@@ -8618,18 +9974,18 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
8618
9974
|
cursorUndoStack: [...previousCursorUndoStack.slice(1 - cursorUndoLimit), new Uint32Array(selections)]
|
|
8619
9975
|
};
|
|
8620
9976
|
}
|
|
8621
|
-
if (state === newEditor || !get$
|
|
9977
|
+
if (state === newEditor || !get$a(uid) || lifecycle?.disposed || get$a(uid).newState.lifecycle !== lifecycle) {
|
|
8622
9978
|
return returnState ? newEditor : undefined;
|
|
8623
9979
|
}
|
|
8624
9980
|
const deferGutterDecorations = !initial && uri === newEditor.uri && lines !== newEditor.lines && Boolean(newEditor.lifecycle);
|
|
8625
9981
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor, deferGutterDecorations);
|
|
8626
|
-
if (!get$
|
|
9982
|
+
if (!get$a(uid) || lifecycle?.disposed || get$a(uid).newState.lifecycle !== lifecycle) {
|
|
8627
9983
|
return returnState ? newEditorWithDerivedState : undefined;
|
|
8628
9984
|
}
|
|
8629
9985
|
// Another command can commit before the renderer consumes this edit.
|
|
8630
9986
|
// Keep its last rendered baseline, including renders completed while we awaited derived state.
|
|
8631
|
-
const renderedState = get$
|
|
8632
|
-
set$
|
|
9987
|
+
const renderedState = get$a(uid)?.oldState ?? oldInstance.oldState;
|
|
9988
|
+
set$b(uid, renderedState, newEditorWithDerivedState);
|
|
8633
9989
|
await dispose$3();
|
|
8634
9990
|
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
8635
9991
|
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
@@ -8642,7 +9998,7 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
8642
9998
|
if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
8643
9999
|
for (const key of getKeys$2()) {
|
|
8644
10000
|
const otherUid = Number(key);
|
|
8645
|
-
const instance = get$
|
|
10001
|
+
const instance = get$a(otherUid);
|
|
8646
10002
|
const editor = instance?.newState;
|
|
8647
10003
|
if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri || editor.applicationId !== finalEditor.applicationId) {
|
|
8648
10004
|
continue;
|
|
@@ -8661,11 +10017,11 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
8661
10017
|
undoStack: finalEditor.undoStack,
|
|
8662
10018
|
visualDecorations: finalEditor.visualDecorations
|
|
8663
10019
|
}, deferGutterDecorations);
|
|
8664
|
-
const latest = get$
|
|
10020
|
+
const latest = get$a(otherUid);
|
|
8665
10021
|
if (!latest || editor.lifecycle?.disposed || latest.newState.lifecycle !== editor.lifecycle) {
|
|
8666
10022
|
continue;
|
|
8667
10023
|
}
|
|
8668
|
-
set$
|
|
10024
|
+
set$b(otherUid, latest.oldState, synchronizedEditor);
|
|
8669
10025
|
if (deferGutterDecorations) {
|
|
8670
10026
|
schedule(synchronizedEditor);
|
|
8671
10027
|
}
|
|
@@ -8697,7 +10053,7 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
|
|
|
8697
10053
|
}, false, returnState);
|
|
8698
10054
|
const focusCommand = uid => {
|
|
8699
10055
|
// DOM focus events can arrive while a queued command is still opening a widget.
|
|
8700
|
-
const widgetRevision = get$
|
|
10056
|
+
const widgetRevision = get$a(uid)?.newState.widgetRevision;
|
|
8701
10057
|
return command(uid, widgetRevision);
|
|
8702
10058
|
};
|
|
8703
10059
|
stateCommands?.add(focusCommand);
|
|
@@ -8730,7 +10086,7 @@ const wrapLatestCommand$1 = (fn, returnState = true) => {
|
|
|
8730
10086
|
const wrapDeferredCommand$1 = (fn, returnState = true) => {
|
|
8731
10087
|
const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
|
|
8732
10088
|
const deferredCommand = async (uid, ...args) => {
|
|
8733
|
-
const snapshot = await enqueue(uid, async () => get$
|
|
10089
|
+
const snapshot = await enqueue(uid, async () => get$a(uid)?.newState);
|
|
8734
10090
|
if (!snapshot) {
|
|
8735
10091
|
return undefined;
|
|
8736
10092
|
}
|
|
@@ -8790,7 +10146,7 @@ const getOpenEditor = (currentEditor, uri) => {
|
|
|
8790
10146
|
return currentEditor;
|
|
8791
10147
|
}
|
|
8792
10148
|
for (const key of getKeys$2()) {
|
|
8793
|
-
const editor = get$
|
|
10149
|
+
const editor = get$a(Number(key))?.newState;
|
|
8794
10150
|
if (editor && !editor.initial && editor.uri === uri && editor.applicationId === currentEditor.applicationId) {
|
|
8795
10151
|
return editor;
|
|
8796
10152
|
}
|
|
@@ -8811,7 +10167,7 @@ const applyWorkspaceEdit = async (editor, changes) => {
|
|
|
8811
10167
|
currentEditor = await scheduleDocumentAndCursorsSelections(openEditor, textChanges);
|
|
8812
10168
|
} else {
|
|
8813
10169
|
await updateOpenEditor(openEditor.uid, textChanges);
|
|
8814
|
-
await invoke$
|
|
10170
|
+
await invoke$7('Editor.renderPending', openEditor.uid);
|
|
8815
10171
|
}
|
|
8816
10172
|
continue;
|
|
8817
10173
|
}
|
|
@@ -9294,8 +10650,8 @@ const closeRename = async editor => {
|
|
|
9294
10650
|
return editor;
|
|
9295
10651
|
}
|
|
9296
10652
|
const renameWidget = widgets[renameWidgetIndex];
|
|
9297
|
-
await invoke$
|
|
9298
|
-
const latest = get$
|
|
10653
|
+
await invoke$5('Rename.close', renameWidget.newState.uid);
|
|
10654
|
+
const latest = get$a(uid);
|
|
9299
10655
|
const {
|
|
9300
10656
|
newState
|
|
9301
10657
|
} = latest;
|
|
@@ -9414,12 +10770,12 @@ const closeColorPicker = editor => {
|
|
|
9414
10770
|
};
|
|
9415
10771
|
};
|
|
9416
10772
|
|
|
9417
|
-
const state$
|
|
10773
|
+
const state$4 = {
|
|
9418
10774
|
compositionText: '',
|
|
9419
10775
|
isComposing: false
|
|
9420
10776
|
};
|
|
9421
10777
|
const compositionStart = (editor, event) => {
|
|
9422
|
-
state$
|
|
10778
|
+
state$4.isComposing = true;
|
|
9423
10779
|
return editor;
|
|
9424
10780
|
};
|
|
9425
10781
|
const getCompositionChanges = (selections, data) => {
|
|
@@ -9429,9 +10785,9 @@ const getCompositionChanges = (selections, data) => {
|
|
|
9429
10785
|
const selectionStartColumn = selections[i + 1];
|
|
9430
10786
|
const selectionEndRow = selections[i + 2];
|
|
9431
10787
|
const selectionEndColumn = selections[i + 3];
|
|
9432
|
-
const startColumnIndex = selectionStartColumn - state$
|
|
10788
|
+
const startColumnIndex = selectionStartColumn - state$4.compositionText.length;
|
|
9433
10789
|
changes.push({
|
|
9434
|
-
deleted: [state$
|
|
10790
|
+
deleted: [state$4.compositionText],
|
|
9435
10791
|
end: {
|
|
9436
10792
|
columnIndex: selectionEndColumn,
|
|
9437
10793
|
rowIndex: selectionEndRow
|
|
@@ -9451,7 +10807,7 @@ const compositionUpdate = (editor, data) => {
|
|
|
9451
10807
|
selections
|
|
9452
10808
|
} = editor;
|
|
9453
10809
|
const changes = getCompositionChanges(selections, data);
|
|
9454
|
-
state$
|
|
10810
|
+
state$4.compositionText = data;
|
|
9455
10811
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9456
10812
|
};
|
|
9457
10813
|
const compositionEnd = (editor, data) => {
|
|
@@ -9459,8 +10815,8 @@ const compositionEnd = (editor, data) => {
|
|
|
9459
10815
|
selections
|
|
9460
10816
|
} = editor;
|
|
9461
10817
|
const changes = getCompositionChanges(selections, data);
|
|
9462
|
-
state$
|
|
9463
|
-
state$
|
|
10818
|
+
state$4.isComposing = false;
|
|
10819
|
+
state$4.compositionText = '';
|
|
9464
10820
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9465
10821
|
};
|
|
9466
10822
|
|
|
@@ -9615,90 +10971,6 @@ const getLineLength = line => {
|
|
|
9615
10971
|
return line.endsWith('\r') ? line.length - 1 : line.length;
|
|
9616
10972
|
};
|
|
9617
10973
|
|
|
9618
|
-
// @ts-ignore
|
|
9619
|
-
const editorGetPositionLeft = (rowIndex, columnIndex, lines, getDelta) => {
|
|
9620
|
-
if (columnIndex === 0) {
|
|
9621
|
-
if (rowIndex === 0) {
|
|
9622
|
-
return {
|
|
9623
|
-
columnIndex: 0,
|
|
9624
|
-
rowIndex: 0
|
|
9625
|
-
};
|
|
9626
|
-
}
|
|
9627
|
-
return {
|
|
9628
|
-
columnIndex: getLineLength(lines[rowIndex - 1]),
|
|
9629
|
-
rowIndex: rowIndex - 1
|
|
9630
|
-
};
|
|
9631
|
-
}
|
|
9632
|
-
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
9633
|
-
return {
|
|
9634
|
-
columnIndex: columnIndex - delta,
|
|
9635
|
-
rowIndex
|
|
9636
|
-
};
|
|
9637
|
-
};
|
|
9638
|
-
|
|
9639
|
-
// @ts-ignore
|
|
9640
|
-
const moveToPositionEqual = (selections, i, rowIndex, columnIndex) => {
|
|
9641
|
-
selections[i] = rowIndex;
|
|
9642
|
-
selections[i + 1] = columnIndex;
|
|
9643
|
-
};
|
|
9644
|
-
|
|
9645
|
-
// @ts-ignore
|
|
9646
|
-
const moveRangeToPosition = (selections, i, rowIndex, columnIndex) => {
|
|
9647
|
-
selections[i] = selections[i + 2] = rowIndex;
|
|
9648
|
-
selections[i + 1] = selections[i + 3] = columnIndex;
|
|
9649
|
-
};
|
|
9650
|
-
|
|
9651
|
-
// @ts-ignore
|
|
9652
|
-
const moveToPositionLeft = (selections, i, rowIndex, columnIndex, lines, getDelta) => {
|
|
9653
|
-
if (columnIndex === 0) {
|
|
9654
|
-
if (rowIndex === 0) {
|
|
9655
|
-
selections[i] = 0;
|
|
9656
|
-
selections[i + 1] = 0;
|
|
9657
|
-
} else {
|
|
9658
|
-
selections[i] = rowIndex - 1;
|
|
9659
|
-
selections[i + 1] = getLineLength(lines[rowIndex - 1]);
|
|
9660
|
-
}
|
|
9661
|
-
} else {
|
|
9662
|
-
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
9663
|
-
selections[i] = rowIndex;
|
|
9664
|
-
selections[i + 1] = columnIndex - delta;
|
|
9665
|
-
}
|
|
9666
|
-
};
|
|
9667
|
-
|
|
9668
|
-
// @ts-ignore
|
|
9669
|
-
|
|
9670
|
-
// @ts-ignore
|
|
9671
|
-
const getNewSelections$a = (selections, lines, getDelta) => {
|
|
9672
|
-
const newSelections = new Uint32Array(selections.length);
|
|
9673
|
-
for (let i = 0; i < selections.length; i += 4) {
|
|
9674
|
-
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
9675
|
-
if (selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn) {
|
|
9676
|
-
if (selectionStartRow === 0 && selectionStartColumn === 0) {
|
|
9677
|
-
newSelections[i] = 0;
|
|
9678
|
-
newSelections[i + 1] = 0;
|
|
9679
|
-
newSelections[i + 2] = 0;
|
|
9680
|
-
newSelections[i + 3] = 0;
|
|
9681
|
-
} else {
|
|
9682
|
-
moveToPositionLeft(newSelections, i, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
9683
|
-
moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
9684
|
-
}
|
|
9685
|
-
} else {
|
|
9686
|
-
moveRangeToPosition(newSelections, i, selections[i], selections[i + 1]);
|
|
9687
|
-
}
|
|
9688
|
-
}
|
|
9689
|
-
return newSelections;
|
|
9690
|
-
};
|
|
9691
|
-
|
|
9692
|
-
// @ts-ignore
|
|
9693
|
-
const editorCursorHorizontalLeft = (editor, getDelta) => {
|
|
9694
|
-
const {
|
|
9695
|
-
lines,
|
|
9696
|
-
selections
|
|
9697
|
-
} = editor;
|
|
9698
|
-
const newSelections = getNewSelections$a(selections, lines, getDelta);
|
|
9699
|
-
return scheduleSelections(editor, newSelections);
|
|
9700
|
-
};
|
|
9701
|
-
|
|
9702
10974
|
/* eslint-disable sonarjs/super-linear-regex */
|
|
9703
10975
|
|
|
9704
10976
|
const characterLeft = (line, columnIndex) => {
|
|
@@ -9810,7 +11082,161 @@ const wordPartRight = (line, columnIndex) => {
|
|
|
9810
11082
|
return tryRegexArray(partialLine, ARRAY_PARTIAL_WORD_RIGHT_2);
|
|
9811
11083
|
};
|
|
9812
11084
|
|
|
11085
|
+
const moveBidiCharacter = (editor, direction, extend = false) => {
|
|
11086
|
+
const {
|
|
11087
|
+
lines,
|
|
11088
|
+
selections
|
|
11089
|
+
} = editor;
|
|
11090
|
+
if (!editor.rtl) {
|
|
11091
|
+
return undefined;
|
|
11092
|
+
}
|
|
11093
|
+
let relevant = false;
|
|
11094
|
+
for (let i = 0; i < selections.length; i += 2) {
|
|
11095
|
+
const row = selections[i];
|
|
11096
|
+
if ([row - 1, row, row + 1].some(index => isBidi(lines[index] || '', true))) {
|
|
11097
|
+
relevant = true;
|
|
11098
|
+
break;
|
|
11099
|
+
}
|
|
11100
|
+
}
|
|
11101
|
+
if (!relevant) {
|
|
11102
|
+
return undefined;
|
|
11103
|
+
}
|
|
11104
|
+
const result = new Uint32Array(selections);
|
|
11105
|
+
const getColumns = row => getVisualColumns(lines[row]);
|
|
11106
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
11107
|
+
let row = selections[i + 2];
|
|
11108
|
+
let column = selections[i + 3];
|
|
11109
|
+
const [startRow, startColumn, endRow, endColumn] = getSelectionPairs(selections, i);
|
|
11110
|
+
if (!extend && (startRow !== endRow || startColumn !== endColumn)) {
|
|
11111
|
+
row = direction === -1 ? startRow : endRow;
|
|
11112
|
+
column = direction === -1 ? startColumn : endColumn;
|
|
11113
|
+
if (startRow === endRow && isBidi(lines[row], true)) {
|
|
11114
|
+
const columns = getColumns(row);
|
|
11115
|
+
const selectedColumns = columns.filter(value => value >= startColumn && value <= endColumn);
|
|
11116
|
+
column = direction === -1 ? selectedColumns[0] : selectedColumns.at(-1);
|
|
11117
|
+
}
|
|
11118
|
+
} else {
|
|
11119
|
+
const line = lines[row];
|
|
11120
|
+
if (isBidi(line, true)) {
|
|
11121
|
+
const columns = getColumns(row);
|
|
11122
|
+
const index = columns.indexOf(column);
|
|
11123
|
+
const next = index + direction;
|
|
11124
|
+
if (next >= 0 && next < columns.length) {
|
|
11125
|
+
column = columns[next];
|
|
11126
|
+
} else if (row + direction >= 0 && row + direction < lines.length) {
|
|
11127
|
+
row += direction;
|
|
11128
|
+
const nextColumns = getColumns(row);
|
|
11129
|
+
column = direction === -1 ? nextColumns.at(-1) : nextColumns[0];
|
|
11130
|
+
}
|
|
11131
|
+
} else if (direction === -1 && column > 0) {
|
|
11132
|
+
column -= characterLeft(line, column);
|
|
11133
|
+
} else if (direction === 1 && column < line.length) {
|
|
11134
|
+
column += characterRight(line, column);
|
|
11135
|
+
} else if (row + direction >= 0 && row + direction < lines.length) {
|
|
11136
|
+
row += direction;
|
|
11137
|
+
const columns = getColumns(row);
|
|
11138
|
+
column = direction === -1 ? columns.at(-1) : columns[0];
|
|
11139
|
+
}
|
|
11140
|
+
}
|
|
11141
|
+
if (!extend) {
|
|
11142
|
+
result[i] = row;
|
|
11143
|
+
result[i + 1] = column;
|
|
11144
|
+
}
|
|
11145
|
+
result[i + 2] = row;
|
|
11146
|
+
result[i + 3] = column;
|
|
11147
|
+
}
|
|
11148
|
+
return scheduleSelections(editor, result);
|
|
11149
|
+
};
|
|
11150
|
+
|
|
11151
|
+
// @ts-ignore
|
|
11152
|
+
const editorGetPositionLeft = (rowIndex, columnIndex, lines, getDelta) => {
|
|
11153
|
+
if (columnIndex === 0) {
|
|
11154
|
+
if (rowIndex === 0) {
|
|
11155
|
+
return {
|
|
11156
|
+
columnIndex: 0,
|
|
11157
|
+
rowIndex: 0
|
|
11158
|
+
};
|
|
11159
|
+
}
|
|
11160
|
+
return {
|
|
11161
|
+
columnIndex: getLineLength(lines[rowIndex - 1]),
|
|
11162
|
+
rowIndex: rowIndex - 1
|
|
11163
|
+
};
|
|
11164
|
+
}
|
|
11165
|
+
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
11166
|
+
return {
|
|
11167
|
+
columnIndex: columnIndex - delta,
|
|
11168
|
+
rowIndex
|
|
11169
|
+
};
|
|
11170
|
+
};
|
|
11171
|
+
|
|
11172
|
+
// @ts-ignore
|
|
11173
|
+
const moveToPositionEqual = (selections, i, rowIndex, columnIndex) => {
|
|
11174
|
+
selections[i] = rowIndex;
|
|
11175
|
+
selections[i + 1] = columnIndex;
|
|
11176
|
+
};
|
|
11177
|
+
|
|
11178
|
+
// @ts-ignore
|
|
11179
|
+
const moveRangeToPosition = (selections, i, rowIndex, columnIndex) => {
|
|
11180
|
+
selections[i] = selections[i + 2] = rowIndex;
|
|
11181
|
+
selections[i + 1] = selections[i + 3] = columnIndex;
|
|
11182
|
+
};
|
|
11183
|
+
|
|
11184
|
+
// @ts-ignore
|
|
11185
|
+
const moveToPositionLeft = (selections, i, rowIndex, columnIndex, lines, getDelta) => {
|
|
11186
|
+
if (columnIndex === 0) {
|
|
11187
|
+
if (rowIndex === 0) {
|
|
11188
|
+
selections[i] = 0;
|
|
11189
|
+
selections[i + 1] = 0;
|
|
11190
|
+
} else {
|
|
11191
|
+
selections[i] = rowIndex - 1;
|
|
11192
|
+
selections[i + 1] = getLineLength(lines[rowIndex - 1]);
|
|
11193
|
+
}
|
|
11194
|
+
} else {
|
|
11195
|
+
const delta = getDelta(lines[rowIndex], columnIndex);
|
|
11196
|
+
selections[i] = rowIndex;
|
|
11197
|
+
selections[i + 1] = columnIndex - delta;
|
|
11198
|
+
}
|
|
11199
|
+
};
|
|
11200
|
+
|
|
11201
|
+
// @ts-ignore
|
|
11202
|
+
|
|
11203
|
+
// @ts-ignore
|
|
11204
|
+
const getNewSelections$a = (selections, lines, getDelta) => {
|
|
11205
|
+
const newSelections = new Uint32Array(selections.length);
|
|
11206
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
11207
|
+
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
11208
|
+
if (selectionStartRow === selectionEndRow && selectionStartColumn === selectionEndColumn) {
|
|
11209
|
+
if (selectionStartRow === 0 && selectionStartColumn === 0) {
|
|
11210
|
+
newSelections[i] = 0;
|
|
11211
|
+
newSelections[i + 1] = 0;
|
|
11212
|
+
newSelections[i + 2] = 0;
|
|
11213
|
+
newSelections[i + 3] = 0;
|
|
11214
|
+
} else {
|
|
11215
|
+
moveToPositionLeft(newSelections, i, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
11216
|
+
moveToPositionLeft(newSelections, i + 2, selectionStartRow, selectionStartColumn, lines, getDelta);
|
|
11217
|
+
}
|
|
11218
|
+
} else {
|
|
11219
|
+
moveRangeToPosition(newSelections, i, selections[i], selections[i + 1]);
|
|
11220
|
+
}
|
|
11221
|
+
}
|
|
11222
|
+
return newSelections;
|
|
11223
|
+
};
|
|
11224
|
+
|
|
11225
|
+
// @ts-ignore
|
|
11226
|
+
const editorCursorHorizontalLeft = (editor, getDelta) => {
|
|
11227
|
+
const {
|
|
11228
|
+
lines,
|
|
11229
|
+
selections
|
|
11230
|
+
} = editor;
|
|
11231
|
+
const newSelections = getNewSelections$a(selections, lines, getDelta);
|
|
11232
|
+
return scheduleSelections(editor, newSelections);
|
|
11233
|
+
};
|
|
11234
|
+
|
|
9813
11235
|
const cursorCharacterLeft = editor => {
|
|
11236
|
+
const bidi = moveBidiCharacter(editor, -1, false);
|
|
11237
|
+
if (bidi) {
|
|
11238
|
+
return bidi;
|
|
11239
|
+
}
|
|
9814
11240
|
return editorCursorHorizontalLeft(editor, characterLeft);
|
|
9815
11241
|
};
|
|
9816
11242
|
|
|
@@ -9876,6 +11302,10 @@ const editorCursorHorizontalRight = (editor, getDelta) => {
|
|
|
9876
11302
|
};
|
|
9877
11303
|
|
|
9878
11304
|
const cursorCharacterRight = editor => {
|
|
11305
|
+
const bidi = moveBidiCharacter(editor, 1, false);
|
|
11306
|
+
if (bidi) {
|
|
11307
|
+
return bidi;
|
|
11308
|
+
}
|
|
9879
11309
|
return editorCursorHorizontalRight(editor, characterRight);
|
|
9880
11310
|
};
|
|
9881
11311
|
|
|
@@ -11149,7 +12579,7 @@ const clear = editor => {
|
|
|
11149
12579
|
decorations: filtered
|
|
11150
12580
|
};
|
|
11151
12581
|
};
|
|
11152
|
-
const set
|
|
12582
|
+
const set = (editor, offset, length) => {
|
|
11153
12583
|
if (matches(editor, offset, length)) {
|
|
11154
12584
|
return editor;
|
|
11155
12585
|
}
|
|
@@ -11309,7 +12739,7 @@ const editorHoverDismissDelay = 500;
|
|
|
11309
12739
|
const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
11310
12740
|
const targetEditorUid = editorUidValue ?? viewletUid;
|
|
11311
12741
|
const editorUid = Number(targetEditorUid);
|
|
11312
|
-
const instance = get$
|
|
12742
|
+
const instance = get$a(editorUid);
|
|
11313
12743
|
if (!instance) {
|
|
11314
12744
|
return;
|
|
11315
12745
|
}
|
|
@@ -11324,7 +12754,7 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
|
11324
12754
|
}
|
|
11325
12755
|
const timeout = setTimeout(async () => {
|
|
11326
12756
|
clear$3(editorUid);
|
|
11327
|
-
const latestInstance = get$
|
|
12757
|
+
const latestInstance = get$a(editorUid);
|
|
11328
12758
|
if (!latestInstance) {
|
|
11329
12759
|
return;
|
|
11330
12760
|
}
|
|
@@ -11341,10 +12771,10 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
|
11341
12771
|
widgetRevision: next(editorUid),
|
|
11342
12772
|
widgets: removeEditorWidget(latestEditor.widgets, Hover)
|
|
11343
12773
|
};
|
|
11344
|
-
set$
|
|
12774
|
+
set$b(editorUid, latestEditor, newEditor);
|
|
11345
12775
|
await RendererWorker.invoke('Editor.renderPending', editorUid);
|
|
11346
12776
|
}, editorHoverDismissDelay);
|
|
11347
|
-
set$
|
|
12777
|
+
set$4(editorUid, {
|
|
11348
12778
|
timeout
|
|
11349
12779
|
});
|
|
11350
12780
|
};
|
|
@@ -11414,7 +12844,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
|
|
|
11414
12844
|
if (!definition) {
|
|
11415
12845
|
return clear(editor);
|
|
11416
12846
|
}
|
|
11417
|
-
return set
|
|
12847
|
+
return set(editor, wordOffset, wordLength);
|
|
11418
12848
|
} catch (error) {
|
|
11419
12849
|
if (isNoDefinitionProviderFoundError(error)) {
|
|
11420
12850
|
return clear(editor);
|
|
@@ -11533,10 +12963,10 @@ const getHover = async (editor, offset) => {
|
|
|
11533
12963
|
};
|
|
11534
12964
|
|
|
11535
12965
|
const getVirtualDomFromMarkdown = async markdown => {
|
|
11536
|
-
const html = await invoke$
|
|
12966
|
+
const html = await invoke$7('Markdown.renderMarkdown', markdown, {
|
|
11537
12967
|
linksExternal: true
|
|
11538
12968
|
});
|
|
11539
|
-
return invoke$
|
|
12969
|
+
return invoke$7('Markdown.getVirtualDom', html);
|
|
11540
12970
|
};
|
|
11541
12971
|
|
|
11542
12972
|
const getLineInfo = (line, tokens, TokenMap) => {
|
|
@@ -11604,7 +13034,7 @@ const hoverWidth = 600;
|
|
|
11604
13034
|
const hoverDocumentationWidth = hoverWidth - 18;
|
|
11605
13035
|
const getEditorHoverInfo = async (editorUid, position) => {
|
|
11606
13036
|
number(editorUid);
|
|
11607
|
-
const instance = get$
|
|
13037
|
+
const instance = get$a(editorUid);
|
|
11608
13038
|
const editor = instance.newState;
|
|
11609
13039
|
const {
|
|
11610
13040
|
selections
|
|
@@ -11738,7 +13168,7 @@ const showDiagnostic = async (editor, diagnostic) => {
|
|
|
11738
13168
|
};
|
|
11739
13169
|
|
|
11740
13170
|
const showHover = async (editor, position, token) => {
|
|
11741
|
-
const instance = get$
|
|
13171
|
+
const instance = get$a(editor.uid);
|
|
11742
13172
|
if (!instance) {
|
|
11743
13173
|
return;
|
|
11744
13174
|
}
|
|
@@ -11747,11 +13177,11 @@ const showHover = async (editor, position, token) => {
|
|
|
11747
13177
|
return;
|
|
11748
13178
|
}
|
|
11749
13179
|
const newEditor = await showHover$1(latestEditor, position);
|
|
11750
|
-
const latestInstance = get$
|
|
13180
|
+
const latestInstance = get$a(editor.uid);
|
|
11751
13181
|
if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$2().token !== token) {
|
|
11752
13182
|
return;
|
|
11753
13183
|
}
|
|
11754
|
-
set$
|
|
13184
|
+
set$b(editor.uid, latestInstance.oldState, newEditor);
|
|
11755
13185
|
await RendererWorker.invoke('Editor.renderPending', editor.uid);
|
|
11756
13186
|
};
|
|
11757
13187
|
|
|
@@ -11774,7 +13204,7 @@ const onHoverIdle = async token => {
|
|
|
11774
13204
|
if (latestToken !== token || !editor) {
|
|
11775
13205
|
return;
|
|
11776
13206
|
}
|
|
11777
|
-
const instance = get$
|
|
13207
|
+
const instance = get$a(editor.uid);
|
|
11778
13208
|
if (!instance || !instance.newState.hoverEnabled) {
|
|
11779
13209
|
return;
|
|
11780
13210
|
}
|
|
@@ -11795,7 +13225,7 @@ const handleMouseMove = async (editor, x, y, altKey) => {
|
|
|
11795
13225
|
}
|
|
11796
13226
|
const token = create$8();
|
|
11797
13227
|
const timeout = setTimeout(onHoverIdle, editorWithoutDefinitionLink.hoverDelay ?? 200, token);
|
|
11798
|
-
set$
|
|
13228
|
+
set$3(editorWithoutDefinitionLink, timeout, x, y, token);
|
|
11799
13229
|
return editorWithoutDefinitionLink;
|
|
11800
13230
|
};
|
|
11801
13231
|
|
|
@@ -12002,20 +13432,20 @@ const advanceSelectionAutoScroll = async editor => {
|
|
|
12002
13432
|
return editorMoveSelection(scrolledEditor, position, false);
|
|
12003
13433
|
};
|
|
12004
13434
|
const continueScrollingAndMovingSelection = async editorUid => {
|
|
12005
|
-
const editor = get$
|
|
13435
|
+
const editor = get$a(editorUid)?.newState;
|
|
12006
13436
|
if (!editor?.isSelecting || !editor.hasListener) {
|
|
12007
13437
|
return;
|
|
12008
13438
|
}
|
|
12009
13439
|
const nextEditor = await advanceSelectionAutoScroll(editor);
|
|
12010
13440
|
const derivedEditor = await updateDerivedState(editor, nextEditor);
|
|
12011
|
-
const currentEditor = get$
|
|
13441
|
+
const currentEditor = get$a(editorUid)?.newState;
|
|
12012
13442
|
if (currentEditor !== editor) {
|
|
12013
13443
|
if (currentEditor?.isSelecting && currentEditor.hasListener) {
|
|
12014
13444
|
requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
|
|
12015
13445
|
}
|
|
12016
13446
|
return;
|
|
12017
13447
|
}
|
|
12018
|
-
set$
|
|
13448
|
+
set$b(editor.uid, editor, derivedEditor);
|
|
12019
13449
|
await RendererWorker.invoke('Editor.renderPending', editor.uid);
|
|
12020
13450
|
if (derivedEditor.hasListener) {
|
|
12021
13451
|
requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
|
|
@@ -12294,7 +13724,7 @@ const handleTouchEnd = (editor, touchEvent) => {
|
|
|
12294
13724
|
// }
|
|
12295
13725
|
};
|
|
12296
13726
|
|
|
12297
|
-
const state$
|
|
13727
|
+
const state$3 = {
|
|
12298
13728
|
deltaY: 0,
|
|
12299
13729
|
touchOffsetY: 0
|
|
12300
13730
|
};
|
|
@@ -12305,8 +13735,8 @@ const handleTouchStart = (editor, touchEvent) => {
|
|
|
12305
13735
|
return;
|
|
12306
13736
|
}
|
|
12307
13737
|
const firstTouch = touchEvent.touches[0];
|
|
12308
|
-
state$
|
|
12309
|
-
state$
|
|
13738
|
+
state$3.touchOffsetY = firstTouch.y;
|
|
13739
|
+
state$3.deltaY = editor.deltaY;
|
|
12310
13740
|
// const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
|
|
12311
13741
|
// EditorMoveSelection.state.position = position
|
|
12312
13742
|
// state.date = Date.now()
|
|
@@ -12346,7 +13776,7 @@ const handleTouchMove = (editor, touchEvent) => {
|
|
|
12346
13776
|
return;
|
|
12347
13777
|
}
|
|
12348
13778
|
const firstTouch = touchEvent.touches[0];
|
|
12349
|
-
const offsetY = state$
|
|
13779
|
+
const offsetY = state$3.deltaY + (state$3.touchOffsetY - firstTouch.y);
|
|
12350
13780
|
setDeltaYFixedValue(editor, offsetY);
|
|
12351
13781
|
};
|
|
12352
13782
|
|
|
@@ -12728,7 +14158,7 @@ const updateEditor = async (editorUid, editor, newEditor) => {
|
|
|
12728
14158
|
return;
|
|
12729
14159
|
}
|
|
12730
14160
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
12731
|
-
set$
|
|
14161
|
+
set$b(editorUid, editor, newEditorWithDerivedState);
|
|
12732
14162
|
};
|
|
12733
14163
|
const applyDocumentEdits = async (editorUid, edits) => {
|
|
12734
14164
|
const editor = getEditor$1(editorUid);
|
|
@@ -12774,18 +14204,18 @@ const launchFindWidgetWorker = async () => {
|
|
|
12774
14204
|
const rpcId = 9002;
|
|
12775
14205
|
const launch = async () => {
|
|
12776
14206
|
// TODO race condition
|
|
12777
|
-
if (get$
|
|
14207
|
+
if (get$b(rpcId)) {
|
|
12778
14208
|
return;
|
|
12779
14209
|
}
|
|
12780
14210
|
const rpc = await launchFindWidgetWorker();
|
|
12781
|
-
set$
|
|
14211
|
+
set$c(rpcId, rpc);
|
|
12782
14212
|
};
|
|
12783
|
-
const invoke$
|
|
12784
|
-
const rpc = get$
|
|
14213
|
+
const invoke$3 = async (method, ...params) => {
|
|
14214
|
+
const rpc = get$b(rpcId);
|
|
12785
14215
|
return await rpc.invoke(method, ...params);
|
|
12786
14216
|
};
|
|
12787
14217
|
const dispose = async () => {
|
|
12788
|
-
const rpc = get$
|
|
14218
|
+
const rpc = get$b(rpcId);
|
|
12789
14219
|
remove$9(rpcId);
|
|
12790
14220
|
if (rpc) {
|
|
12791
14221
|
await rpc.dispose();
|
|
@@ -12804,14 +14234,14 @@ const launchHoverWorker = async () => {
|
|
|
12804
14234
|
return rpc;
|
|
12805
14235
|
};
|
|
12806
14236
|
|
|
12807
|
-
const state$
|
|
14237
|
+
const state$2 = {};
|
|
12808
14238
|
const getOrCreate$1 = () => {
|
|
12809
|
-
if (!state$
|
|
12810
|
-
state$
|
|
14239
|
+
if (!state$2.workerPromise) {
|
|
14240
|
+
state$2.workerPromise = launchHoverWorker();
|
|
12811
14241
|
}
|
|
12812
|
-
return state$
|
|
14242
|
+
return state$2.workerPromise;
|
|
12813
14243
|
};
|
|
12814
|
-
const invoke$
|
|
14244
|
+
const invoke$2 = async (method, ...params) => {
|
|
12815
14245
|
const worker = await getOrCreate$1();
|
|
12816
14246
|
return await worker.invoke(method, ...params);
|
|
12817
14247
|
};
|
|
@@ -12824,14 +14254,14 @@ const launchSourceActionWorker = async () => {
|
|
|
12824
14254
|
return rpc;
|
|
12825
14255
|
};
|
|
12826
14256
|
|
|
12827
|
-
const state$
|
|
14257
|
+
const state$1 = {};
|
|
12828
14258
|
const getOrCreate = () => {
|
|
12829
|
-
if (!state$
|
|
12830
|
-
state$
|
|
14259
|
+
if (!state$1.workerPromise) {
|
|
14260
|
+
state$1.workerPromise = launchSourceActionWorker();
|
|
12831
14261
|
}
|
|
12832
|
-
return state$
|
|
14262
|
+
return state$1.workerPromise;
|
|
12833
14263
|
};
|
|
12834
|
-
const invoke$
|
|
14264
|
+
const invoke$1 = async (method, ...params) => {
|
|
12835
14265
|
const worker = await getOrCreate();
|
|
12836
14266
|
return await worker.invoke(method, ...params);
|
|
12837
14267
|
};
|
|
@@ -12839,17 +14269,17 @@ const invoke$2 = async (method, ...params) => {
|
|
|
12839
14269
|
const getWidgetInvoke = widgetId => {
|
|
12840
14270
|
switch (widgetId) {
|
|
12841
14271
|
case ColorPicker$2:
|
|
12842
|
-
return invoke$
|
|
14272
|
+
return invoke$6;
|
|
12843
14273
|
case Completion:
|
|
12844
|
-
return invoke$5;
|
|
12845
|
-
case Find:
|
|
12846
14274
|
return invoke$4;
|
|
12847
|
-
case
|
|
14275
|
+
case Find:
|
|
12848
14276
|
return invoke$3;
|
|
14277
|
+
case Hover:
|
|
14278
|
+
return invoke$2;
|
|
12849
14279
|
case Rename$1:
|
|
12850
|
-
return invoke$
|
|
14280
|
+
return invoke$5;
|
|
12851
14281
|
case SourceAction$1:
|
|
12852
|
-
return invoke$
|
|
14282
|
+
return invoke$1;
|
|
12853
14283
|
default:
|
|
12854
14284
|
return undefined;
|
|
12855
14285
|
}
|
|
@@ -12860,7 +14290,7 @@ const Close = 'Close';
|
|
|
12860
14290
|
|
|
12861
14291
|
const getEditorByWidgetUid = (widgetUid, widgetId) => {
|
|
12862
14292
|
for (const key of getKeys$2()) {
|
|
12863
|
-
const editor = get$
|
|
14293
|
+
const editor = get$a(Number(key)).newState;
|
|
12864
14294
|
const widgets = editor.widgets || [];
|
|
12865
14295
|
for (const widget of widgets) {
|
|
12866
14296
|
if (widget.id === widgetId && widget.newState.uid === widgetUid) {
|
|
@@ -12874,7 +14304,7 @@ const getEditor = (editorOrUid, widgetId) => {
|
|
|
12874
14304
|
if (editorOrUid && editorOrUid.widgets) {
|
|
12875
14305
|
return editorOrUid;
|
|
12876
14306
|
}
|
|
12877
|
-
const instance = get$
|
|
14307
|
+
const instance = get$a(editorOrUid);
|
|
12878
14308
|
if (instance && instance.newState && instance.newState.widgets) {
|
|
12879
14309
|
return instance.newState;
|
|
12880
14310
|
}
|
|
@@ -12906,16 +14336,16 @@ const createFn = (key, name, widgetId) => {
|
|
|
12906
14336
|
} = state;
|
|
12907
14337
|
const invoke = getWidgetInvoke(widgetId);
|
|
12908
14338
|
await invoke(`${name}.${key}`, uid, ...args);
|
|
12909
|
-
const latestAfterInvoke = get$
|
|
14339
|
+
const latestAfterInvoke = get$a(editor.uid).newState;
|
|
12910
14340
|
const latestChildIndex = latestAfterInvoke.widgets.findIndex(isWidget);
|
|
12911
14341
|
if (latestChildIndex === -1) {
|
|
12912
|
-
set$
|
|
14342
|
+
set$b(editor.uid, editor, latestAfterInvoke);
|
|
12913
14343
|
await dispose$3();
|
|
12914
14344
|
return latestAfterInvoke;
|
|
12915
14345
|
}
|
|
12916
14346
|
const diff = await invoke(`${name}.diff2`, uid);
|
|
12917
14347
|
const commands = await invoke(`${name}.render2`, uid, diff);
|
|
12918
|
-
const latest = get$
|
|
14348
|
+
const latest = get$a(editor.uid).newState;
|
|
12919
14349
|
if (shouldClose) {
|
|
12920
14350
|
const newEditor = {
|
|
12921
14351
|
...latest,
|
|
@@ -12923,7 +14353,7 @@ const createFn = (key, name, widgetId) => {
|
|
|
12923
14353
|
widgetRevision,
|
|
12924
14354
|
widgets: removeEditorWidget(latest.widgets, widgetId)
|
|
12925
14355
|
};
|
|
12926
|
-
set$
|
|
14356
|
+
set$b(editor.uid, latest, newEditor);
|
|
12927
14357
|
return newEditor;
|
|
12928
14358
|
}
|
|
12929
14359
|
const newState = {
|
|
@@ -12931,7 +14361,7 @@ const createFn = (key, name, widgetId) => {
|
|
|
12931
14361
|
commands
|
|
12932
14362
|
};
|
|
12933
14363
|
const newEditor = updateWidget(latest, widgetId, newState);
|
|
12934
|
-
set$
|
|
14364
|
+
set$b(editor.uid, editor, newEditor);
|
|
12935
14365
|
return newEditor;
|
|
12936
14366
|
};
|
|
12937
14367
|
return fn;
|
|
@@ -12998,9 +14428,14 @@ const focusFindInput = editor => {
|
|
|
12998
14428
|
} = widget.newState;
|
|
12999
14429
|
const newState = {
|
|
13000
14430
|
...widget.newState,
|
|
13001
|
-
commands: [[FocusSelector, uid, `[name="${SearchValue}"]`]]
|
|
14431
|
+
commands: [[SetFocusContext, FindWidget], [FocusSelector, uid, `[name="${SearchValue}"]`]]
|
|
13002
14432
|
};
|
|
13003
|
-
return updateWidget(
|
|
14433
|
+
return updateWidget({
|
|
14434
|
+
...editor,
|
|
14435
|
+
additionalFocus: 0,
|
|
14436
|
+
focus: FindWidget,
|
|
14437
|
+
focused: false
|
|
14438
|
+
}, Find, newState);
|
|
13004
14439
|
};
|
|
13005
14440
|
const {
|
|
13006
14441
|
close: close$4,
|
|
@@ -13109,10 +14544,10 @@ const loadContent$2 = async (state, parentUid, savedState) => {
|
|
|
13109
14544
|
y
|
|
13110
14545
|
} = editor;
|
|
13111
14546
|
await launch();
|
|
13112
|
-
await invoke$
|
|
13113
|
-
await invoke$
|
|
13114
|
-
const diff = await invoke$
|
|
13115
|
-
const commands = await invoke$
|
|
14547
|
+
await invoke$3('FindWidget.create', uid, x, y, width, height, parentUid);
|
|
14548
|
+
await invoke$3('FindWidget.loadContent', uid, savedState);
|
|
14549
|
+
const diff = await invoke$3('FindWidget.diff2', uid);
|
|
14550
|
+
const commands = await invoke$3('FindWidget.render2', uid, diff);
|
|
13116
14551
|
return {
|
|
13117
14552
|
...state,
|
|
13118
14553
|
commands
|
|
@@ -13187,15 +14622,15 @@ const newStateGenerator$1 = async (state, parentUid) => {
|
|
|
13187
14622
|
} = state;
|
|
13188
14623
|
const {
|
|
13189
14624
|
newState
|
|
13190
|
-
} = get$
|
|
14625
|
+
} = get$a(parentUid);
|
|
13191
14626
|
const {
|
|
13192
14627
|
applicationId,
|
|
13193
14628
|
languageId
|
|
13194
14629
|
} = newState;
|
|
13195
|
-
await invoke$
|
|
13196
|
-
await invoke$
|
|
13197
|
-
const diff = await invoke$
|
|
13198
|
-
const commands = await invoke$
|
|
14630
|
+
await invoke$5('Rename.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
14631
|
+
await invoke$5('Rename.loadContent', uid);
|
|
14632
|
+
const diff = await invoke$5('Rename.diff2', uid);
|
|
14633
|
+
const commands = await invoke$5('Rename.render2', uid, diff);
|
|
13199
14634
|
return {
|
|
13200
14635
|
...state,
|
|
13201
14636
|
commands
|
|
@@ -13212,7 +14647,7 @@ const openRename = async editor => {
|
|
|
13212
14647
|
if (!word) {
|
|
13213
14648
|
return editor;
|
|
13214
14649
|
}
|
|
13215
|
-
const editorState = get$
|
|
14650
|
+
const editorState = get$a(editor.uid);
|
|
13216
14651
|
if (!editorState) {
|
|
13217
14652
|
return editor;
|
|
13218
14653
|
}
|
|
@@ -13226,7 +14661,7 @@ const openRename = async editor => {
|
|
|
13226
14661
|
if (!prepareRenameResult || typeof prepareRenameResult !== 'object') {
|
|
13227
14662
|
return editor;
|
|
13228
14663
|
}
|
|
13229
|
-
const latestEditor = get$
|
|
14664
|
+
const latestEditor = get$a(editor.uid)?.newState;
|
|
13230
14665
|
if (latestEditor !== editor) {
|
|
13231
14666
|
return latestEditor || editor;
|
|
13232
14667
|
}
|
|
@@ -13363,7 +14798,7 @@ const paste = async (editor, pastedText) => {
|
|
|
13363
14798
|
cause: error
|
|
13364
14799
|
});
|
|
13365
14800
|
}
|
|
13366
|
-
const currentEditor = get$
|
|
14801
|
+
const currentEditor = get$a(editor.uid)?.newState;
|
|
13367
14802
|
if (!currentEditor || currentEditor.uri !== editor.uri || currentEditor.languageId !== 'markdown') {
|
|
13368
14803
|
try {
|
|
13369
14804
|
await invoke$a(editor.applicationId, 'FileSystem.remove', savedImage.uri);
|
|
@@ -13579,10 +15014,18 @@ const editorSelectAllRight = editor => {
|
|
|
13579
15014
|
|
|
13580
15015
|
// @ts-ignore
|
|
13581
15016
|
const selectCharacterLeft = editor => {
|
|
15017
|
+
const bidi = moveBidiCharacter(editor, -1, true);
|
|
15018
|
+
if (bidi) {
|
|
15019
|
+
return bidi;
|
|
15020
|
+
}
|
|
13582
15021
|
return editorSelectHorizontalLeft(editor, characterLeft);
|
|
13583
15022
|
};
|
|
13584
15023
|
|
|
13585
15024
|
const selectCharacterRight = editor => {
|
|
15025
|
+
const bidi = moveBidiCharacter(editor, 1, true);
|
|
15026
|
+
if (bidi) {
|
|
15027
|
+
return bidi;
|
|
15028
|
+
}
|
|
13586
15029
|
return editorSelectHorizontalRight(editor, characterRight);
|
|
13587
15030
|
};
|
|
13588
15031
|
|
|
@@ -14119,7 +15562,7 @@ const paddingLeft = 8;
|
|
|
14119
15562
|
const paddingRight = 8;
|
|
14120
15563
|
const getSignatureHelpInfo = async editorUid => {
|
|
14121
15564
|
number(editorUid);
|
|
14122
|
-
const instance = get$
|
|
15565
|
+
const instance = get$a(editorUid);
|
|
14123
15566
|
const editor = instance.newState;
|
|
14124
15567
|
const {
|
|
14125
15568
|
selections
|
|
@@ -14237,14 +15680,14 @@ const newStateGenerator = async (state, parentUid) => {
|
|
|
14237
15680
|
} = state;
|
|
14238
15681
|
const {
|
|
14239
15682
|
newState
|
|
14240
|
-
} = get$
|
|
15683
|
+
} = get$a(parentUid);
|
|
14241
15684
|
const {
|
|
14242
15685
|
languageId
|
|
14243
15686
|
} = newState;
|
|
14244
|
-
await invoke$
|
|
14245
|
-
await invoke$
|
|
14246
|
-
const diff = await invoke$
|
|
14247
|
-
const commands = await invoke$
|
|
15687
|
+
await invoke$1('SourceActions.create', uid, x, y, width, height, parentUid, languageId);
|
|
15688
|
+
await invoke$1('SourceActions.loadContent', uid);
|
|
15689
|
+
const diff = await invoke$1('SourceActions.diff2', uid);
|
|
15690
|
+
const commands = await invoke$1('SourceActions.render2', uid, diff);
|
|
14248
15691
|
return {
|
|
14249
15692
|
...state,
|
|
14250
15693
|
commands
|
|
@@ -15978,7 +17421,7 @@ const getEditorSourceActions = async editorId => {
|
|
|
15978
17421
|
}
|
|
15979
17422
|
const {
|
|
15980
17423
|
newState
|
|
15981
|
-
} = get$
|
|
17424
|
+
} = get$a(editorId);
|
|
15982
17425
|
const extensions = await invoke$9(newState.applicationId, 'Extensions.getAllExtensions', newState.assetDir, newState.platform);
|
|
15983
17426
|
return extensions.filter(extension => !extension.disabled).flatMap(extension => extension.codeActions || []).filter(action => action.languageId === newState.languageId);
|
|
15984
17427
|
};
|
|
@@ -16072,13 +17515,13 @@ const getSelections2 = editorUid => {
|
|
|
16072
17515
|
return selections;
|
|
16073
17516
|
};
|
|
16074
17517
|
const setSelections2 = async (editorUid, selections) => {
|
|
16075
|
-
const requested = get$
|
|
17518
|
+
const requested = get$a(editorUid);
|
|
16076
17519
|
if (!requested || requested.newState.lifecycle?.disposed) {
|
|
16077
17520
|
return;
|
|
16078
17521
|
}
|
|
16079
17522
|
const requestedLifecycle = requested.newState.lifecycle;
|
|
16080
17523
|
await enqueue(editorUid, async () => {
|
|
16081
|
-
const instance = get$
|
|
17524
|
+
const instance = get$a(editorUid);
|
|
16082
17525
|
if (!instance || instance.newState.lifecycle?.disposed || instance.newState.lifecycle !== requestedLifecycle) {
|
|
16083
17526
|
return;
|
|
16084
17527
|
}
|
|
@@ -16088,11 +17531,11 @@ const setSelections2 = async (editorUid, selections) => {
|
|
|
16088
17531
|
} = editor;
|
|
16089
17532
|
const newEditor = setSelections$2(editor, selections);
|
|
16090
17533
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
16091
|
-
const current = get$
|
|
17534
|
+
const current = get$a(editorUid);
|
|
16092
17535
|
if (!current || lifecycle?.disposed || current.newState.lifecycle !== lifecycle) {
|
|
16093
17536
|
return;
|
|
16094
17537
|
}
|
|
16095
|
-
set$
|
|
17538
|
+
set$b(editorUid, current.oldState, newEditorWithDerivedState);
|
|
16096
17539
|
});
|
|
16097
17540
|
};
|
|
16098
17541
|
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
@@ -16117,7 +17560,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
16117
17560
|
widgets: newWidgets
|
|
16118
17561
|
};
|
|
16119
17562
|
const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
|
|
16120
|
-
set$
|
|
17563
|
+
set$b(editorUid, editor, newEditorWithDerivedState);
|
|
16121
17564
|
await setFocus(FocusEditorText);
|
|
16122
17565
|
if (unsetAdditionalFocus$1) {
|
|
16123
17566
|
await unsetAdditionalFocus(unsetAdditionalFocus$1);
|
|
@@ -16148,7 +17591,7 @@ const ensure = async (fontName, fontUrl) => {
|
|
|
16148
17591
|
const getComponentState = uid => {
|
|
16149
17592
|
const {
|
|
16150
17593
|
newState
|
|
16151
|
-
} = get$
|
|
17594
|
+
} = get$a(uid);
|
|
16152
17595
|
return {
|
|
16153
17596
|
...newState,
|
|
16154
17597
|
cursorUndoStack: newState.cursorUndoStack?.map(selection => [...selection]),
|
|
@@ -16652,7 +18095,7 @@ const getProblems = async () => {
|
|
|
16652
18095
|
const keys = getKeys$2();
|
|
16653
18096
|
const diagnostics = keys.flatMap(key => {
|
|
16654
18097
|
const numericKey = Number(key);
|
|
16655
|
-
const editor = get$
|
|
18098
|
+
const editor = get$a(numericKey);
|
|
16656
18099
|
if (!editor?.newState) {
|
|
16657
18100
|
return [];
|
|
16658
18101
|
}
|
|
@@ -16824,10 +18267,10 @@ const createCommandMap = commands => ({
|
|
|
16824
18267
|
if (typeof fn !== 'function') {
|
|
16825
18268
|
throw new TypeError(`Editor event command not found: ${command}`);
|
|
16826
18269
|
}
|
|
16827
|
-
const editor = get$
|
|
18270
|
+
const editor = get$a(uid)?.newState;
|
|
16828
18271
|
if (!editor) return;
|
|
16829
18272
|
await fn(uid, ...args);
|
|
16830
|
-
const current = get$
|
|
18273
|
+
const current = get$a(uid)?.newState;
|
|
16831
18274
|
if (!current || editor.lifecycle?.disposed || current.lifecycle !== editor.lifecycle) return;
|
|
16832
18275
|
// The wrapped command has released the document queue before requesting a
|
|
16833
18276
|
// render; a diff can now run without waiting on its own command.
|
|
@@ -16837,35 +18280,13 @@ const createCommandMap = commands => ({
|
|
|
16837
18280
|
}
|
|
16838
18281
|
});
|
|
16839
18282
|
|
|
16840
|
-
const state$1 = {
|
|
16841
|
-
rpc: undefined
|
|
16842
|
-
};
|
|
16843
|
-
const isConnected = () => {
|
|
16844
|
-
const {
|
|
16845
|
-
rpc
|
|
16846
|
-
} = state$1;
|
|
16847
|
-
return rpc !== undefined;
|
|
16848
|
-
};
|
|
16849
|
-
const set = value => {
|
|
16850
|
-
state$1.rpc = value;
|
|
16851
|
-
};
|
|
16852
|
-
const invoke$1 = (method, ...params) => {
|
|
16853
|
-
const {
|
|
16854
|
-
rpc
|
|
16855
|
-
} = state$1;
|
|
16856
|
-
if (!rpc) {
|
|
16857
|
-
throw new Error('Editor renderer process is not connected');
|
|
16858
|
-
}
|
|
16859
|
-
return rpc.invoke(method, ...params);
|
|
16860
|
-
};
|
|
16861
|
-
|
|
16862
18283
|
const handleMessagePort = async (port, rpcId) => {
|
|
16863
18284
|
const rpc = await create$b({
|
|
16864
18285
|
commandMap: {},
|
|
16865
18286
|
messagePort: port
|
|
16866
18287
|
});
|
|
16867
18288
|
if (rpcId) {
|
|
16868
|
-
set$
|
|
18289
|
+
set$c(rpcId, rpc);
|
|
16869
18290
|
await initializeListener(rpcId);
|
|
16870
18291
|
}
|
|
16871
18292
|
};
|
|
@@ -16874,7 +18295,7 @@ const handleDirectMessagePort = async (port, commands) => {
|
|
|
16874
18295
|
commandMap: createCommandMap(commands),
|
|
16875
18296
|
messagePort: port
|
|
16876
18297
|
});
|
|
16877
|
-
set(rpc);
|
|
18298
|
+
set$6(rpc);
|
|
16878
18299
|
};
|
|
16879
18300
|
|
|
16880
18301
|
const getBreadcrumbFileIcon = async (uri, applicationId) => {
|
|
@@ -17023,7 +18444,7 @@ const getHorizontalVirtualizationThreshold = value => {
|
|
|
17023
18444
|
return Math.floor(threshold);
|
|
17024
18445
|
};
|
|
17025
18446
|
const getEditorPreferences = async applicationId => {
|
|
17026
|
-
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, formatActions, hoverEnabled, hoverDelay, horizontalVirtualizationThreshold, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics', applicationId), getFontFamily(applicationId), getFontSize(applicationId), getFontWeight(applicationId), get$3('editor.formatOnSave', applicationId), get$3('editor.formatActions', applicationId), get$3('editor.hover', applicationId), get$3('editor.hoverDelay', applicationId), get$3('editor.horizontalVirtualizationThreshold', applicationId), get$3('editor.messageDelay', applicationId), isAutoClosingBracketsEnabled(applicationId), isAutoClosingQuotesEnabled(applicationId), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(applicationId), getLineNumbers(applicationId), getHighlightActiveLineNumber(applicationId), getRowHeight(applicationId), getTabSize(applicationId), getLetterSpacing(applicationId), getCompletionTriggerCharacters(), getMinimapEnabled(applicationId), getMergeConflictActionsEnabled(applicationId), get$3('breadcrumbs.enabled', applicationId), get$3('editor.insertSpaces', applicationId), get$3('editor.dragAndDrop', applicationId), get$3('editor.roundedSelection', applicationId), get$3('editor.combineWhitespaceTokens', applicationId), get$3('editor.selectedTextOccurrenceMatching', applicationId)]);
|
|
18447
|
+
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, formatActions, hoverEnabled, hoverDelay, horizontalVirtualizationThreshold, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, rtl, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics', applicationId), getFontFamily(applicationId), getFontSize(applicationId), getFontWeight(applicationId), get$3('editor.formatOnSave', applicationId), get$3('editor.formatActions', applicationId), get$3('editor.hover', applicationId), get$3('editor.hoverDelay', applicationId), get$3('editor.horizontalVirtualizationThreshold', applicationId), get$3('editor.messageDelay', applicationId), isAutoClosingBracketsEnabled(applicationId), isAutoClosingQuotesEnabled(applicationId), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(applicationId), getLineNumbers(applicationId), getHighlightActiveLineNumber(applicationId), getRowHeight(applicationId), getTabSize(applicationId), getLetterSpacing(applicationId), getCompletionTriggerCharacters(), getMinimapEnabled(applicationId), getMergeConflictActionsEnabled(applicationId), get$3('editor.rtl', applicationId), get$3('breadcrumbs.enabled', applicationId), get$3('editor.insertSpaces', applicationId), get$3('editor.dragAndDrop', applicationId), get$3('editor.roundedSelection', applicationId), get$3('editor.combineWhitespaceTokens', applicationId), get$3('editor.selectedTextOccurrenceMatching', applicationId)]);
|
|
17027
18448
|
return {
|
|
17028
18449
|
breadcrumbsEnabled: breadcrumbsEnabled ?? false,
|
|
17029
18450
|
combineWhitespaceTokens: combineWhitespaceTokens ?? true,
|
|
@@ -17051,6 +18472,7 @@ const getEditorPreferences = async applicationId => {
|
|
|
17051
18472
|
minimapEnabled,
|
|
17052
18473
|
roundedSelection: roundedSelection === true,
|
|
17053
18474
|
rowHeight,
|
|
18475
|
+
rtl: rtl === true,
|
|
17054
18476
|
selectedTextOccurrenceMatching: getSelectedTextOccurrenceMatching(selectedTextOccurrenceMatching),
|
|
17055
18477
|
tabSize
|
|
17056
18478
|
};
|
|
@@ -17086,9 +18508,9 @@ const updateFindWidget = async state => {
|
|
|
17086
18508
|
const {
|
|
17087
18509
|
uid
|
|
17088
18510
|
} = widget.newState;
|
|
17089
|
-
await invoke$
|
|
17090
|
-
const diff = await invoke$
|
|
17091
|
-
const commands = await invoke$
|
|
18511
|
+
await invoke$3('FindWidget.handleSettingsChanged', uid);
|
|
18512
|
+
const diff = await invoke$3('FindWidget.diff2', uid);
|
|
18513
|
+
const commands = await invoke$3('FindWidget.render2', uid, diff);
|
|
17092
18514
|
return updateWidget(state, Find, {
|
|
17093
18515
|
...widget.newState,
|
|
17094
18516
|
commands
|
|
@@ -17212,7 +18634,7 @@ const getWidgetHotReloadDescriptor = widgetId => {
|
|
|
17212
18634
|
switch (widgetId) {
|
|
17213
18635
|
case Find:
|
|
17214
18636
|
return {
|
|
17215
|
-
invoke: invoke$
|
|
18637
|
+
invoke: invoke$3,
|
|
17216
18638
|
name: 'FindWidget'
|
|
17217
18639
|
};
|
|
17218
18640
|
default:
|
|
@@ -17255,7 +18677,7 @@ const restoreWidgetState = async (keys, savedStates) => {
|
|
|
17255
18677
|
const newEditors = [];
|
|
17256
18678
|
for (const key of keys) {
|
|
17257
18679
|
const editorUid = parseInt(key);
|
|
17258
|
-
const editor = get$
|
|
18680
|
+
const editor = get$a(editorUid);
|
|
17259
18681
|
if (!editor?.newState || !Array.isArray(editor.newState.widgets)) {
|
|
17260
18682
|
continue;
|
|
17261
18683
|
}
|
|
@@ -17308,7 +18730,7 @@ const saveSingleWidgetState = async (savedStates, key, widget) => {
|
|
|
17308
18730
|
const saveWidgetState = async keys => {
|
|
17309
18731
|
const savedStates = Object.create(null);
|
|
17310
18732
|
for (const key of keys) {
|
|
17311
|
-
const editor = get$
|
|
18733
|
+
const editor = get$a(parseInt(key));
|
|
17312
18734
|
if (!editor?.newState || !Array.isArray(editor.newState.widgets)) {
|
|
17313
18735
|
continue;
|
|
17314
18736
|
}
|
|
@@ -17337,7 +18759,7 @@ const hotReload = async () => {
|
|
|
17337
18759
|
await relaunchWorkers();
|
|
17338
18760
|
const newEditors = await restoreWidgetState(keys, savedStates);
|
|
17339
18761
|
for (const editor of newEditors) {
|
|
17340
|
-
set$
|
|
18762
|
+
set$b(editor.newState.uid, editor.oldState, editor.newState);
|
|
17341
18763
|
}
|
|
17342
18764
|
|
|
17343
18765
|
// TODO ask renderer worker to rerender all editors
|
|
@@ -17375,7 +18797,7 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
|
|
|
17375
18797
|
if (syntaxHighlightingEnabled) {
|
|
17376
18798
|
setEnabled$1(true);
|
|
17377
18799
|
const syntaxRpc = await createSyntaxHighlightingWorkerRpc();
|
|
17378
|
-
set$
|
|
18800
|
+
set$9(syntaxRpc);
|
|
17379
18801
|
}
|
|
17380
18802
|
if (syncIncremental) {
|
|
17381
18803
|
setEnabled(true);
|
|
@@ -17596,6 +19018,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
17596
19018
|
minimapEnabled,
|
|
17597
19019
|
roundedSelection,
|
|
17598
19020
|
rowHeight,
|
|
19021
|
+
rtl,
|
|
17599
19022
|
selectedTextOccurrenceMatching,
|
|
17600
19023
|
tabSize
|
|
17601
19024
|
} = await getEditorPreferences(state.applicationId);
|
|
@@ -17638,6 +19061,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
17638
19061
|
minimapEnabled,
|
|
17639
19062
|
roundedSelection,
|
|
17640
19063
|
rowHeight,
|
|
19064
|
+
rtl,
|
|
17641
19065
|
selectedTextOccurrenceMatching,
|
|
17642
19066
|
tabSize,
|
|
17643
19067
|
tokenizerId: state.tokenizerId
|
|
@@ -17647,7 +19071,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
17647
19071
|
let existingEditor;
|
|
17648
19072
|
if (!forceReload) {
|
|
17649
19073
|
for (const key of getKeys$2()) {
|
|
17650
|
-
const editor = get$
|
|
19074
|
+
const editor = get$a(Number(key))?.newState;
|
|
17651
19075
|
if (editor && editor.id !== id && !editor.initial && editor.uri === uri && editor.applicationId === state.applicationId) {
|
|
17652
19076
|
existingEditor = editor;
|
|
17653
19077
|
break;
|
|
@@ -17830,14 +19254,14 @@ const refreshGutterDecorations = async editor => {
|
|
|
17830
19254
|
};
|
|
17831
19255
|
const refreshGutterDecorationsAll = async () => {
|
|
17832
19256
|
for (const key of getKeys$2()) {
|
|
17833
|
-
const editor = get$
|
|
19257
|
+
const editor = get$a(Number(key))?.newState;
|
|
17834
19258
|
if (editor) {
|
|
17835
19259
|
const refreshedEditor = await refreshGutterDecorations(editor);
|
|
17836
|
-
const latest = get$
|
|
19260
|
+
const latest = get$a(editor.id);
|
|
17837
19261
|
if (!latest) {
|
|
17838
19262
|
continue;
|
|
17839
19263
|
}
|
|
17840
|
-
set$
|
|
19264
|
+
set$b(editor.id, latest.oldState, {
|
|
17841
19265
|
...latest.newState,
|
|
17842
19266
|
gutterDecorations: refreshedEditor.gutterDecorations
|
|
17843
19267
|
});
|
|
@@ -17877,6 +19301,8 @@ const getCss = (uid, rowHeight, scrollBarHeight, scrollBarTop, scrollBarWidth, s
|
|
|
17877
19301
|
--ScrollBarWidth: ${scrollBarWidth}px;
|
|
17878
19302
|
--ScrollBarLeft: ${scrollBarLeft}px;
|
|
17879
19303
|
}
|
|
19304
|
+
.EditorBidiRun { display: inline-block; direction: ltr; unicode-bidi: bidi-override; }
|
|
19305
|
+
.EditorBidiRunRtl { direction: rtl; }
|
|
17880
19306
|
.EditorRow { contain: var(--EditorRowContain, strict); }
|
|
17881
19307
|
${editorSelector} .SelectionTopLeft { border-top-left-radius: 3px; }
|
|
17882
19308
|
${editorSelector} .SelectionTopRight { border-top-right-radius: 3px; }
|
|
@@ -18360,7 +19786,7 @@ const addMergeConflictActions = (dom, rowIndex) => {
|
|
|
18360
19786
|
}, text(label));
|
|
18361
19787
|
}
|
|
18362
19788
|
};
|
|
18363
|
-
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, diagnostics = [], deltaX = 0, width = Infinity, charWidth = 1, tabSize = 2, lines = [], horizontalVirtualizationThreshold = 500, horizontalVisibleRanges = []) => {
|
|
19789
|
+
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, diagnostics = [], deltaX = 0, width = Infinity, charWidth = 1, tabSize = 2, lines = [], horizontalVirtualizationThreshold = 500, horizontalVisibleRanges = [], rtl = false) => {
|
|
18364
19790
|
const dom = [];
|
|
18365
19791
|
const actualViewRows = visibleViewLineIndices.length === 0 ? Array.from({
|
|
18366
19792
|
length: textInfos.length
|
|
@@ -18389,13 +19815,43 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
18389
19815
|
if (rowIndex === problemsHighlightedRow) {
|
|
18390
19816
|
className = mergeClassNames(className, 'EditorProblemsHighlightedRow');
|
|
18391
19817
|
}
|
|
19818
|
+
const bidiText = rtl && isBidi(line || tokenParts.map(part => part.text).join(''), rtl) ? tokenParts.map(part => part.text).join('') : '';
|
|
19819
|
+
const runs = bidiText ? getRuns(bidiText) : undefined;
|
|
18392
19820
|
dom.push({
|
|
18393
|
-
childCount: tokenParts.length + rowDecorations.length,
|
|
19821
|
+
childCount: (runs?.length ?? tokenParts.length) + rowDecorations.length,
|
|
18394
19822
|
className,
|
|
18395
19823
|
translate: difference === 0 ? '' : px(difference),
|
|
18396
19824
|
type: Div
|
|
18397
19825
|
});
|
|
18398
|
-
|
|
19826
|
+
if (runs) {
|
|
19827
|
+
for (const run of runs) {
|
|
19828
|
+
let offset = 0;
|
|
19829
|
+
const parts = [];
|
|
19830
|
+
for (const part of tokenParts) {
|
|
19831
|
+
const start = Math.max(run.start, offset);
|
|
19832
|
+
const end = Math.min(run.end, offset + part.text.length);
|
|
19833
|
+
if (start < end) {
|
|
19834
|
+
parts.push({
|
|
19835
|
+
className: part.className,
|
|
19836
|
+
text: part.text.slice(start - offset, end - offset)
|
|
19837
|
+
});
|
|
19838
|
+
}
|
|
19839
|
+
offset += part.text.length;
|
|
19840
|
+
}
|
|
19841
|
+
dom.push({
|
|
19842
|
+
childCount: parts.length,
|
|
19843
|
+
className: run.level % 2 ? 'EditorBidiRun EditorBidiRunRtl' : 'EditorBidiRun',
|
|
19844
|
+
type: Span
|
|
19845
|
+
});
|
|
19846
|
+
for (const part of parts) {
|
|
19847
|
+
dom.push({
|
|
19848
|
+
childCount: 1,
|
|
19849
|
+
className: part.className,
|
|
19850
|
+
type: Span
|
|
19851
|
+
}, text(part.text));
|
|
19852
|
+
}
|
|
19853
|
+
}
|
|
19854
|
+
} else for (const {
|
|
18399
19855
|
className,
|
|
18400
19856
|
text: tokenText
|
|
18401
19857
|
} of tokenParts) {
|
|
@@ -18413,8 +19869,8 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
18413
19869
|
return dom;
|
|
18414
19870
|
};
|
|
18415
19871
|
|
|
18416
|
-
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2) => {
|
|
18417
|
-
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, 0, Infinity, 1, tabSize, lines, 500, horizontalVisibleRanges);
|
|
19872
|
+
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2, rtl = false) => {
|
|
19873
|
+
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, 0, Infinity, 1, tabSize, lines, 500, horizontalVisibleRanges, rtl);
|
|
18418
19874
|
return [{
|
|
18419
19875
|
childCount: visibleViewLineIndices.length || textInfos.length,
|
|
18420
19876
|
className: 'EditorRows',
|
|
@@ -18511,8 +19967,8 @@ const editorLayersNode = {
|
|
|
18511
19967
|
className: 'EditorLayers',
|
|
18512
19968
|
type: Div
|
|
18513
19969
|
};
|
|
18514
|
-
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2, textDecorationDom = []) => {
|
|
18515
|
-
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos, textDecorationDom)];
|
|
19970
|
+
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false, unnecessaryDiagnostics = [], horizontalVisibleRanges = [], lines = [], tabSize = 2, textDecorationDom = [], rtl = false) => {
|
|
19971
|
+
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, rtl), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos, textDecorationDom)];
|
|
18516
19972
|
};
|
|
18517
19973
|
|
|
18518
19974
|
const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
@@ -18590,6 +20046,7 @@ const getEditorContentVirtualDom = ({
|
|
|
18590
20046
|
lines = [],
|
|
18591
20047
|
problemsHighlightedRow = -1,
|
|
18592
20048
|
roundedSelection = false,
|
|
20049
|
+
rtl = false,
|
|
18593
20050
|
scrollBarDiagnostics = [],
|
|
18594
20051
|
scrollBarHeight = 0,
|
|
18595
20052
|
scrollBarWidth = 0,
|
|
@@ -18604,7 +20061,7 @@ const getEditorContentVirtualDom = ({
|
|
|
18604
20061
|
return [{
|
|
18605
20062
|
...editorContentNode,
|
|
18606
20063
|
className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
|
|
18607
|
-
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
|
|
20064
|
+
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics, horizontalVisibleRanges, lines, tabSize, textDecorationDom, rtl), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
|
|
18608
20065
|
};
|
|
18609
20066
|
|
|
18610
20067
|
const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
|
|
@@ -18770,6 +20227,7 @@ const getEditorVirtualDom = ({
|
|
|
18770
20227
|
primarySelectionIndex = 0,
|
|
18771
20228
|
problemsHighlightedRow = -1,
|
|
18772
20229
|
roundedSelection = false,
|
|
20230
|
+
rtl = false,
|
|
18773
20231
|
scrollBarDiagnostics = [],
|
|
18774
20232
|
scrollBarHeight = 0,
|
|
18775
20233
|
scrollBarWidth = 0,
|
|
@@ -18834,6 +20292,7 @@ const getEditorVirtualDom = ({
|
|
|
18834
20292
|
lines,
|
|
18835
20293
|
problemsHighlightedRow,
|
|
18836
20294
|
roundedSelection,
|
|
20295
|
+
rtl,
|
|
18837
20296
|
scrollBarDiagnostics,
|
|
18838
20297
|
scrollBarHeight,
|
|
18839
20298
|
scrollBarWidth,
|
|
@@ -18938,6 +20397,9 @@ const canRenderPlainTextAppend = (oldState, newState) => {
|
|
|
18938
20397
|
}
|
|
18939
20398
|
const oldLine = oldLines[0];
|
|
18940
20399
|
const newLine = newLines[0];
|
|
20400
|
+
if (oldState.rtl !== newState.rtl || isBidi(oldLine, oldState.rtl) || isBidi(newLine, newState.rtl)) {
|
|
20401
|
+
return false;
|
|
20402
|
+
}
|
|
18941
20403
|
if (newLine.length <= oldLine.length || !newLine.startsWith(oldLine) || /[\r\n]/.test(newLine.slice(oldLine.length))) {
|
|
18942
20404
|
return false;
|
|
18943
20405
|
}
|
|
@@ -19036,7 +20498,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
19036
20498
|
const textAppendPaths = getTextAppendPaths$1(newState.uid);
|
|
19037
20499
|
if (renderedDom && textAppendPaths && canRenderPlainTextAppend(oldState, newState)) {
|
|
19038
20500
|
const newDom = updateTextAppendDom(renderedDom, newState, textAppendPaths);
|
|
19039
|
-
set$
|
|
20501
|
+
set$1(newState.uid, newDom, textAppendPaths);
|
|
19040
20502
|
const patches = getTextAppendPatches(newState, textAppendPaths);
|
|
19041
20503
|
return [SetPatches, newState.uid, patches];
|
|
19042
20504
|
}
|
|
@@ -19044,7 +20506,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
19044
20506
|
const newDom = getDom(newState);
|
|
19045
20507
|
const patches = diffTree(oldDom, newDom);
|
|
19046
20508
|
const newTextAppendPaths = newState.languageId === 'plaintext' && newState.lines.length === 1 ? getTextAppendPaths(newDom) : undefined;
|
|
19047
|
-
set$
|
|
20509
|
+
set$1(newState.uid, newDom, newTextAppendPaths);
|
|
19048
20510
|
if (patches.length === 0) {
|
|
19049
20511
|
return [];
|
|
19050
20512
|
}
|
|
@@ -19161,7 +20623,7 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
19161
20623
|
};
|
|
19162
20624
|
|
|
19163
20625
|
const render2 = (uid, _diffResult) => {
|
|
19164
|
-
const editor = get$
|
|
20626
|
+
const editor = get$a(uid);
|
|
19165
20627
|
if (!editor) {
|
|
19166
20628
|
return [];
|
|
19167
20629
|
}
|
|
@@ -19171,7 +20633,7 @@ const render2 = (uid, _diffResult) => {
|
|
|
19171
20633
|
} = editor;
|
|
19172
20634
|
// Diagnostics can change after the caller calculated its diff in a separate RPC.
|
|
19173
20635
|
const diffResult = diff(oldState, newState);
|
|
19174
|
-
set$
|
|
20636
|
+
set$b(uid, newState, newState);
|
|
19175
20637
|
const commands = applyRender(oldState, newState, diffResult);
|
|
19176
20638
|
return commands;
|
|
19177
20639
|
};
|
|
@@ -19179,7 +20641,7 @@ const render2 = (uid, _diffResult) => {
|
|
|
19179
20641
|
const queues = new Map();
|
|
19180
20642
|
const focusCommands = new Set(['Viewlet.focus', 'Viewlet.focusSelector', 'Viewlet.setFocusContext', 'Viewlet.setAdditionalFocus', 'Viewlet.unsetAdditionalFocus']);
|
|
19181
20643
|
const renderDirect = async (uid, preserveFocus) => {
|
|
19182
|
-
const instance = get$
|
|
20644
|
+
const instance = get$a(uid);
|
|
19183
20645
|
if (!instance) return [];
|
|
19184
20646
|
const {
|
|
19185
20647
|
newState,
|
|
@@ -19195,7 +20657,7 @@ const renderDirect = async (uid, preserveFocus) => {
|
|
|
19195
20657
|
// Widget creation/declarations and focus contexts must still pass through
|
|
19196
20658
|
// renderer-worker. Replace only DOM patches, preserving command order.
|
|
19197
20659
|
if (isConnected() && command[0] === 'Viewlet.setPatches' && command[1] === uid) {
|
|
19198
|
-
const transactionId = await invoke$
|
|
20660
|
+
const transactionId = await invoke$8('Viewlet.queueCommands', uid, [command]);
|
|
19199
20661
|
result.push(['Viewlet.commitPending', uid, transactionId]);
|
|
19200
20662
|
} else {
|
|
19201
20663
|
result.push(command);
|
|
@@ -19203,17 +20665,17 @@ const renderDirect = async (uid, preserveFocus) => {
|
|
|
19203
20665
|
}
|
|
19204
20666
|
return result;
|
|
19205
20667
|
} catch (error) {
|
|
19206
|
-
const latest = get$
|
|
20668
|
+
const latest = get$a(uid);
|
|
19207
20669
|
if (latest?.newState.lifecycle === newState.lifecycle && latest.oldState === newState) {
|
|
19208
20670
|
// A rejected queue RPC must not acknowledge patches that never arrived.
|
|
19209
|
-
set$
|
|
19210
|
-
if (oldDom) set$
|
|
20671
|
+
set$b(uid, oldState, latest.newState);
|
|
20672
|
+
if (oldDom) set$1(uid, oldDom, oldPaths);else dispose$2(uid);
|
|
19211
20673
|
}
|
|
19212
20674
|
throw error;
|
|
19213
20675
|
}
|
|
19214
20676
|
};
|
|
19215
20677
|
const renderDirect2 = async (uid, preserveFocus = false) => {
|
|
19216
|
-
const lifecycle = get$
|
|
20678
|
+
const lifecycle = get$a(uid)?.newState.lifecycle;
|
|
19217
20679
|
const previous = queues.get(uid);
|
|
19218
20680
|
const {
|
|
19219
20681
|
promise,
|
|
@@ -19222,7 +20684,7 @@ const renderDirect2 = async (uid, preserveFocus = false) => {
|
|
|
19222
20684
|
queues.set(uid, promise);
|
|
19223
20685
|
if (previous) await previous;
|
|
19224
20686
|
try {
|
|
19225
|
-
if (get$
|
|
20687
|
+
if (get$a(uid)?.newState.lifecycle !== lifecycle) return [];
|
|
19226
20688
|
return await renderDirect(uid, preserveFocus);
|
|
19227
20689
|
} finally {
|
|
19228
20690
|
resolve();
|
|
@@ -19250,10 +20712,10 @@ const renderLines = {
|
|
|
19250
20712
|
visibleLineIndices,
|
|
19251
20713
|
visibleViewLineIndices
|
|
19252
20714
|
} = newState;
|
|
19253
|
-
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || [], newState.deltaX, newState.width, newState.charWidth, newState.tabSize, newState.lines, newState.horizontalVirtualizationThreshold, newState.horizontalVisibleRanges);
|
|
20715
|
+
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || [], newState.deltaX, newState.width, newState.charWidth, newState.tabSize, newState.lines, newState.horizontalVirtualizationThreshold, newState.horizontalVisibleRanges, newState.rtl);
|
|
19254
20716
|
return [/* method */'setText', dom];
|
|
19255
20717
|
},
|
|
19256
|
-
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.diagnostics === newState.diagnostics && oldState.deltaX === newState.deltaX && oldState.charWidth === newState.charWidth && oldState.tabSize === newState.tabSize && oldState.gutterWidth === newState.gutterWidth && oldState.horizontalVirtualizationThreshold === newState.horizontalVirtualizationThreshold && oldState.fontFamily === newState.fontFamily && oldState.fontSize === newState.fontSize && oldState.fontWeight === newState.fontWeight && oldState.letterSpacing === newState.letterSpacing && oldState.isMonospaceFont === newState.isMonospaceFont && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
|
|
20718
|
+
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.diagnostics === newState.diagnostics && oldState.deltaX === newState.deltaX && oldState.charWidth === newState.charWidth && oldState.tabSize === newState.tabSize && oldState.rtl === newState.rtl && oldState.gutterWidth === newState.gutterWidth && oldState.horizontalVirtualizationThreshold === newState.horizontalVirtualizationThreshold && oldState.fontFamily === newState.fontFamily && oldState.fontSize === newState.fontSize && oldState.fontWeight === newState.fontWeight && oldState.letterSpacing === newState.letterSpacing && oldState.isMonospaceFont === newState.isMonospaceFont && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
|
|
19257
20719
|
};
|
|
19258
20720
|
const renderSelections = {
|
|
19259
20721
|
apply: (oldState, newState) => {
|
|
@@ -19327,7 +20789,7 @@ const renderWidgets = {
|
|
|
19327
20789
|
};
|
|
19328
20790
|
const render$7 = [renderLines, renderSelections, renderCss, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets, renderFocusContext, renderAdditionalFocusContext];
|
|
19329
20791
|
const renderEditor = async id => {
|
|
19330
|
-
const instance = get$
|
|
20792
|
+
const instance = get$a(id);
|
|
19331
20793
|
if (!instance) {
|
|
19332
20794
|
return [];
|
|
19333
20795
|
}
|
|
@@ -19336,7 +20798,7 @@ const renderEditor = async id => {
|
|
|
19336
20798
|
oldState
|
|
19337
20799
|
} = instance;
|
|
19338
20800
|
const commands = [];
|
|
19339
|
-
set$
|
|
20801
|
+
set$b(id, newState, newState);
|
|
19340
20802
|
for (const item of render$7) {
|
|
19341
20803
|
if (item.isEqual(oldState, newState)) {
|
|
19342
20804
|
continue;
|
|
@@ -19650,7 +21112,7 @@ const unregisterListener = (listenerType, rpcId) => {
|
|
|
19650
21112
|
};
|
|
19651
21113
|
|
|
19652
21114
|
const invoke = async (method, ...params) => {
|
|
19653
|
-
const worker = get$
|
|
21115
|
+
const worker = get$b(RpcId.DebugWorker);
|
|
19654
21116
|
return worker.invoke(method, ...params);
|
|
19655
21117
|
};
|
|
19656
21118
|
|
|
@@ -19666,7 +21128,7 @@ const getKey = () => {
|
|
|
19666
21128
|
const updateDebugInfo = async debugId => {
|
|
19667
21129
|
const newInfo = await getDebugHighlight(debugId);
|
|
19668
21130
|
const key = getKey();
|
|
19669
|
-
const instance = get$
|
|
21131
|
+
const instance = get$a(key);
|
|
19670
21132
|
if (!instance) {
|
|
19671
21133
|
return;
|
|
19672
21134
|
}
|
|
@@ -19678,7 +21140,7 @@ const updateDebugInfo = async debugId => {
|
|
|
19678
21140
|
...newState,
|
|
19679
21141
|
highlightedLine: newInfo.rowIndex
|
|
19680
21142
|
};
|
|
19681
|
-
set$
|
|
21143
|
+
set$b(key, oldState, newEditor);
|
|
19682
21144
|
// @ts-ignore
|
|
19683
21145
|
await RendererWorker.invoke('Editor.rerender', key);
|
|
19684
21146
|
};
|
|
@@ -19732,7 +21194,7 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
|
|
|
19732
21194
|
clear$3(uid);
|
|
19733
21195
|
}
|
|
19734
21196
|
await command(uid, ...args);
|
|
19735
|
-
const editor = get$
|
|
21197
|
+
const editor = get$a(uid)?.newState;
|
|
19736
21198
|
if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
|
|
19737
21199
|
void updateAutomaticCompletionDeferred(uid).then(() => RendererWorker.invoke('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
|
|
19738
21200
|
}
|
|
@@ -20388,15 +21850,15 @@ const EditorMessageWidget = {
|
|
|
20388
21850
|
};
|
|
20389
21851
|
|
|
20390
21852
|
const registerWidgets = () => {
|
|
20391
|
-
set$
|
|
20392
|
-
set$
|
|
20393
|
-
set$
|
|
20394
|
-
set$
|
|
20395
|
-
set$
|
|
20396
|
-
set$
|
|
20397
|
-
set$
|
|
20398
|
-
set$
|
|
20399
|
-
set$
|
|
21853
|
+
set$a(ColorPicker$2, EditorColorPickerWidget);
|
|
21854
|
+
set$a(Completion, EditorCompletionWidget);
|
|
21855
|
+
set$a(CompletionDetail, EditorCompletionDetailWidget);
|
|
21856
|
+
set$a(Find, EditorFindWidget);
|
|
21857
|
+
set$a(Hover, EditorHoverWidget);
|
|
21858
|
+
set$a(Message, EditorMessageWidget);
|
|
21859
|
+
set$a(Rename$1, EditorRenameWidget);
|
|
21860
|
+
set$a(SourceAction$1, EditorSourceActionWidget);
|
|
21861
|
+
set$a(CodeGenerator, EditorCodeGeneratorWidget);
|
|
20400
21862
|
};
|
|
20401
21863
|
|
|
20402
21864
|
const reservedIds = new Set();
|
|
@@ -20410,7 +21872,7 @@ const createEmbeddedEditor = async options => {
|
|
|
20410
21872
|
const {
|
|
20411
21873
|
id
|
|
20412
21874
|
} = options;
|
|
20413
|
-
if (reservedIds.has(id) || get$
|
|
21875
|
+
if (reservedIds.has(id) || get$a(id)) {
|
|
20414
21876
|
throw new Error(`Editor already exists: ${id}`);
|
|
20415
21877
|
}
|
|
20416
21878
|
reservedIds.add(id);
|
|
@@ -20429,7 +21891,7 @@ const createEmbeddedEditor = async options => {
|
|
|
20429
21891
|
if (closed) {
|
|
20430
21892
|
throw new Error(`Editor is disposed: ${id}`);
|
|
20431
21893
|
}
|
|
20432
|
-
return get$
|
|
21894
|
+
return get$a(id).newState;
|
|
20433
21895
|
};
|
|
20434
21896
|
const ignoreFailure = async command => {
|
|
20435
21897
|
try {
|
|
@@ -20441,7 +21903,7 @@ const createEmbeddedEditor = async options => {
|
|
|
20441
21903
|
const run = async (previous, fn, args) => {
|
|
20442
21904
|
await previous;
|
|
20443
21905
|
await fn(id, ...args);
|
|
20444
|
-
return get$
|
|
21906
|
+
return get$a(id).newState;
|
|
20445
21907
|
};
|
|
20446
21908
|
const execute = (command, ...args) => {
|
|
20447
21909
|
if (closed) {
|