@lvce-editor/file-search-worker 5.0.0 → 5.1.0
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/dist/fileSearchWorkerMain.js +1977 -2015
- package/package.json +1 -1
|
@@ -786,7 +786,7 @@ const register$2 = commandMap => {
|
|
|
786
786
|
const getCommand = key => {
|
|
787
787
|
return commands[key];
|
|
788
788
|
};
|
|
789
|
-
const execute
|
|
789
|
+
const execute = (command, ...args) => {
|
|
790
790
|
const fn = getCommand(command);
|
|
791
791
|
if (!fn) {
|
|
792
792
|
throw new Error(`command not found ${command}`);
|
|
@@ -824,7 +824,7 @@ const logError = () => {
|
|
|
824
824
|
};
|
|
825
825
|
const handleMessage = event => {
|
|
826
826
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
827
|
-
const actualExecute = event?.target?.execute || execute
|
|
827
|
+
const actualExecute = event?.target?.execute || execute;
|
|
828
828
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
829
829
|
};
|
|
830
830
|
const handleIpc = ipc => {
|
|
@@ -891,7 +891,7 @@ const minimumSliderSize = 20;
|
|
|
891
891
|
const Command = '>';
|
|
892
892
|
const Symbol$1 = '@';
|
|
893
893
|
const WorkspaceSymbol$1 = '#';
|
|
894
|
-
const GoToLine = ':';
|
|
894
|
+
const GoToLine$1 = ':';
|
|
895
895
|
const View$1 = 'view ';
|
|
896
896
|
const None$2 = '';
|
|
897
897
|
|
|
@@ -905,8 +905,8 @@ const getQuickPickPrefix = value => {
|
|
|
905
905
|
if (value.startsWith(WorkspaceSymbol$1)) {
|
|
906
906
|
return WorkspaceSymbol$1;
|
|
907
907
|
}
|
|
908
|
-
if (value.startsWith(GoToLine)) {
|
|
909
|
-
return GoToLine;
|
|
908
|
+
if (value.startsWith(GoToLine$1)) {
|
|
909
|
+
return GoToLine$1;
|
|
910
910
|
}
|
|
911
911
|
if (value.startsWith(View$1)) {
|
|
912
912
|
return View$1;
|
|
@@ -914,34 +914,46 @@ const getQuickPickPrefix = value => {
|
|
|
914
914
|
return None$2;
|
|
915
915
|
};
|
|
916
916
|
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
stack,
|
|
929
|
-
name
|
|
930
|
-
};
|
|
931
|
-
await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
|
|
932
|
-
};
|
|
933
|
-
const warn = (...args) => {
|
|
934
|
-
console.warn(...args);
|
|
935
|
-
};
|
|
917
|
+
const CommandPalette = 'quickPick://commandPalette';
|
|
918
|
+
const Commands = 'quickPick://commands';
|
|
919
|
+
const File$2 = 'quickPick://file';
|
|
920
|
+
const EveryThing = 'quickPick://everything';
|
|
921
|
+
const Recent = 'quickPick://recent';
|
|
922
|
+
const ColorTheme = 'quickPick://color-theme';
|
|
923
|
+
const Symbol = 'quickPick://symbol';
|
|
924
|
+
const View = 'quickPick://view';
|
|
925
|
+
const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
926
|
+
const Custom = 'quickPick://custom';
|
|
927
|
+
const GoToLine = 'quickPick://go-to-line';
|
|
936
928
|
|
|
937
|
-
|
|
938
|
-
|
|
929
|
+
// TODO use numeric enum for quickpick entry id
|
|
930
|
+
const getQuickPickProviderId = prefix => {
|
|
931
|
+
switch (prefix) {
|
|
932
|
+
case Command:
|
|
933
|
+
return Commands;
|
|
934
|
+
case Symbol$1:
|
|
935
|
+
return Symbol;
|
|
936
|
+
case WorkspaceSymbol$1:
|
|
937
|
+
return WorkspaceSymbol;
|
|
938
|
+
case GoToLine$1:
|
|
939
|
+
return GoToLine;
|
|
940
|
+
case View$1:
|
|
941
|
+
return View;
|
|
942
|
+
default:
|
|
943
|
+
return File$2;
|
|
944
|
+
}
|
|
939
945
|
};
|
|
940
|
-
|
|
941
|
-
|
|
946
|
+
|
|
947
|
+
const state$b = Object.create(null);
|
|
948
|
+
const register$1 = modules => {
|
|
949
|
+
Object.assign(state$b, modules);
|
|
942
950
|
};
|
|
943
|
-
const
|
|
944
|
-
|
|
951
|
+
const get$1 = moduleId => {
|
|
952
|
+
const module = state$b[moduleId];
|
|
953
|
+
if (!module) {
|
|
954
|
+
throw new Error(`unknown module "${moduleId}"`);
|
|
955
|
+
}
|
|
956
|
+
return module;
|
|
945
957
|
};
|
|
946
958
|
|
|
947
959
|
const Hide = 'hide';
|
|
@@ -1009,2162 +1021,2192 @@ const quickOpen = () => {
|
|
|
1009
1021
|
return i18nString(QuickOpen);
|
|
1010
1022
|
};
|
|
1011
1023
|
|
|
1012
|
-
const name$
|
|
1013
|
-
const getPlaceholder$
|
|
1014
|
-
return typeNameofCommandToRun();
|
|
1015
|
-
};
|
|
1016
|
-
const getLabel$5 = () => {
|
|
1024
|
+
const name$9 = 'noop';
|
|
1025
|
+
const getPlaceholder$9 = () => {
|
|
1017
1026
|
return '';
|
|
1018
1027
|
};
|
|
1019
|
-
const getNoResults$
|
|
1020
|
-
return
|
|
1021
|
-
label: noMatchingResults()
|
|
1022
|
-
};
|
|
1023
|
-
};
|
|
1024
|
-
|
|
1025
|
-
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
1026
|
-
const getBuiltinPicks = async () => {
|
|
1027
|
-
const builtinPicks = getAll();
|
|
1028
|
-
return builtinPicks;
|
|
1029
|
-
};
|
|
1030
|
-
const prefixIdWithExt = item => {
|
|
1031
|
-
if (!item.label) {
|
|
1032
|
-
warn('[QuickPick] item has missing label', item);
|
|
1033
|
-
}
|
|
1034
|
-
if (!item.id) {
|
|
1035
|
-
warn('[QuickPick] item has missing id', item);
|
|
1036
|
-
}
|
|
1037
|
-
return {
|
|
1038
|
-
...item,
|
|
1039
|
-
id: `ext.${item.id}`,
|
|
1040
|
-
label: item.label || item.id
|
|
1041
|
-
};
|
|
1042
|
-
};
|
|
1043
|
-
const getExtensionPicks = async () => {
|
|
1044
|
-
try {
|
|
1045
|
-
// TODO don't call this every time
|
|
1046
|
-
const extensionPicks = await invoke$1('ExtensionHost.getCommands');
|
|
1047
|
-
if (!extensionPicks) {
|
|
1048
|
-
return [];
|
|
1049
|
-
}
|
|
1050
|
-
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
1051
|
-
return mappedPicks;
|
|
1052
|
-
} catch (error) {
|
|
1053
|
-
console.error(`Failed to get extension picks: ${error}`);
|
|
1054
|
-
return [];
|
|
1055
|
-
}
|
|
1056
|
-
};
|
|
1057
|
-
|
|
1058
|
-
// TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
|
|
1059
|
-
|
|
1060
|
-
const getPicks$a = async () => {
|
|
1061
|
-
const builtinPicks = await getBuiltinPicks();
|
|
1062
|
-
const extensionPicks = await getExtensionPicks();
|
|
1063
|
-
const allPicks = [...builtinPicks, ...extensionPicks];
|
|
1064
|
-
return allPicks;
|
|
1065
|
-
};
|
|
1066
|
-
const getVisibleItems$a = async (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
1067
|
-
const visibleItems = picks.map((pick, index) => ({
|
|
1068
|
-
description: pick.description || '',
|
|
1069
|
-
fileIcon: '',
|
|
1070
|
-
icon: getPickIcon$7(),
|
|
1071
|
-
isActive: index + minLineY === focusedIndex,
|
|
1072
|
-
label: getPickLabel$7(pick),
|
|
1073
|
-
matches: [],
|
|
1074
|
-
posInSet: index + minLineY + 1,
|
|
1075
|
-
setSize
|
|
1076
|
-
}));
|
|
1077
|
-
return visibleItems;
|
|
1078
|
-
};
|
|
1079
|
-
const shouldHide = item => {
|
|
1080
|
-
if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
|
|
1081
|
-
return false;
|
|
1082
|
-
}
|
|
1083
|
-
return true;
|
|
1028
|
+
const getNoResults$9 = () => {
|
|
1029
|
+
return noResults();
|
|
1084
1030
|
};
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
1088
|
-
await invoke$1(item.id, ...args);
|
|
1089
|
-
if (shouldHide(item)) {
|
|
1090
|
-
return {
|
|
1091
|
-
command: Hide
|
|
1092
|
-
};
|
|
1093
|
-
}
|
|
1094
|
-
return {
|
|
1095
|
-
command: KeepOpen
|
|
1096
|
-
};
|
|
1031
|
+
const getPicks$9 = async value => {
|
|
1032
|
+
return [];
|
|
1097
1033
|
};
|
|
1098
|
-
const
|
|
1099
|
-
const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
|
|
1100
|
-
try {
|
|
1101
|
-
await invoke$1('ExtensionHost.executeCommand', id);
|
|
1102
|
-
} catch (error) {
|
|
1103
|
-
await handleError(error, false);
|
|
1104
|
-
await showErrorDialog(error);
|
|
1105
|
-
}
|
|
1034
|
+
const selectPick$9 = async item => {
|
|
1106
1035
|
return {
|
|
1107
1036
|
command: Hide
|
|
1108
1037
|
};
|
|
1109
1038
|
};
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
return selectPickExtension(item);
|
|
1113
|
-
}
|
|
1114
|
-
return selectPickBuiltin(item);
|
|
1115
|
-
};
|
|
1116
|
-
const getFilterValue$a = value => {
|
|
1117
|
-
return value.trim();
|
|
1118
|
-
};
|
|
1119
|
-
const getPickFilterValue$8 = pick => {
|
|
1120
|
-
return pick.label;
|
|
1039
|
+
const getFilterValue$9 = value => {
|
|
1040
|
+
return value;
|
|
1121
1041
|
};
|
|
1122
|
-
const
|
|
1123
|
-
return pick
|
|
1042
|
+
const getPickFilterValue$9 = pick => {
|
|
1043
|
+
return pick;
|
|
1124
1044
|
};
|
|
1125
|
-
const
|
|
1126
|
-
return
|
|
1045
|
+
const getVisibleItems$9 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
1046
|
+
return [];
|
|
1127
1047
|
};
|
|
1128
1048
|
|
|
1129
|
-
const
|
|
1049
|
+
const QuickPickNoop = {
|
|
1130
1050
|
__proto__: null,
|
|
1131
|
-
getFilterValue: getFilterValue$
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
getVisibleItems: getVisibleItems$a,
|
|
1140
|
-
name: name$a,
|
|
1141
|
-
selectPick: selectPick$a
|
|
1051
|
+
getFilterValue: getFilterValue$9,
|
|
1052
|
+
getNoResults: getNoResults$9,
|
|
1053
|
+
getPickFilterValue: getPickFilterValue$9,
|
|
1054
|
+
getPicks: getPicks$9,
|
|
1055
|
+
getPlaceholder: getPlaceholder$9,
|
|
1056
|
+
getVisibleItems: getVisibleItems$9,
|
|
1057
|
+
name: name$9,
|
|
1058
|
+
selectPick: selectPick$9
|
|
1142
1059
|
};
|
|
1143
1060
|
|
|
1144
|
-
|
|
1145
|
-
const File$2 = 7;
|
|
1146
|
-
|
|
1147
|
-
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1148
|
-
const getProtocol = uri => {
|
|
1149
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1150
|
-
if (protocolMatch) {
|
|
1151
|
-
return protocolMatch[1];
|
|
1152
|
-
}
|
|
1153
|
-
return '';
|
|
1154
|
-
};
|
|
1061
|
+
// TODO avoid global variable
|
|
1155
1062
|
|
|
1156
|
-
|
|
1157
|
-
return invoke$1('Workspace.getPath');
|
|
1158
|
-
};
|
|
1063
|
+
// TODO don't store provider in state, only serialized value like provider-id
|
|
1159
1064
|
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1065
|
+
const state$a = {
|
|
1066
|
+
// providerId: PROVIDER_NOOP,
|
|
1067
|
+
provider: QuickPickNoop,
|
|
1068
|
+
prefix: 'string-that-should-never-match-another-string'
|
|
1162
1069
|
};
|
|
1163
1070
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1169
|
-
return state$
|
|
1071
|
+
/**
|
|
1072
|
+
* @type {string}
|
|
1073
|
+
*/
|
|
1074
|
+
const name$8 = 'everything';
|
|
1075
|
+
const getPlaceholder$8 = () => {
|
|
1076
|
+
return state$a.provider.getPlaceholder();
|
|
1170
1077
|
};
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const protocol = getProtocol(path);
|
|
1174
|
-
// TODO call different providers depending on protocol
|
|
1175
|
-
const fn = getModule(protocol);
|
|
1176
|
-
const result = await fn(path, value, prepare, assetDir);
|
|
1177
|
-
return result;
|
|
1078
|
+
const getLabel$5 = () => {
|
|
1079
|
+
return '';
|
|
1178
1080
|
};
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const pathBaseName = path => {
|
|
1182
|
-
return path.slice(path.lastIndexOf('/') + 1);
|
|
1081
|
+
const getNoResults$8 = () => {
|
|
1082
|
+
return state$a.provider.getNoResults();
|
|
1183
1083
|
};
|
|
1084
|
+
const getPicks$8 = async value => {
|
|
1085
|
+
const prefix = getQuickPickPrefix(value);
|
|
1184
1086
|
|
|
1185
|
-
// TODO
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1087
|
+
// TODO race condition
|
|
1088
|
+
if (state$a.prefix !== prefix) {
|
|
1089
|
+
state$a.prefix = prefix;
|
|
1090
|
+
const providerId = getQuickPickProviderId(prefix);
|
|
1091
|
+
const provider = get$1(providerId);
|
|
1092
|
+
state$a.provider = provider;
|
|
1191
1093
|
}
|
|
1192
|
-
|
|
1094
|
+
// TODO this line is a bit duplicated with getFilterValue
|
|
1095
|
+
const slicedValue = value.slice(prefix.length).trimStart();
|
|
1096
|
+
const picks = await state$a.provider.getPicks(slicedValue);
|
|
1097
|
+
return picks;
|
|
1193
1098
|
};
|
|
1194
|
-
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
return files;
|
|
1099
|
+
const selectPick$8 = item => {
|
|
1100
|
+
const {
|
|
1101
|
+
provider
|
|
1102
|
+
} = state$a;
|
|
1103
|
+
return provider.selectPick(item);
|
|
1200
1104
|
};
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
return '';
|
|
1105
|
+
const openCommandPalette = () => {
|
|
1106
|
+
// show('>')
|
|
1204
1107
|
};
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1108
|
+
const openView = () => {
|
|
1109
|
+
// show('view ')
|
|
1207
1110
|
};
|
|
1208
|
-
const
|
|
1209
|
-
return
|
|
1210
|
-
label: noMatchingResults()
|
|
1211
|
-
};
|
|
1111
|
+
const getFilterValue$8 = value => {
|
|
1112
|
+
return value.slice(state$a.prefix.length).trim();
|
|
1212
1113
|
};
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
}
|
|
1219
|
-
const files = await searchFile$4(workspace, searchValue);
|
|
1220
|
-
return files;
|
|
1114
|
+
const getPickFilterValue$8 = pick => {
|
|
1115
|
+
const {
|
|
1116
|
+
provider
|
|
1117
|
+
} = state$a;
|
|
1118
|
+
return provider.getPickFilterValue(pick);
|
|
1221
1119
|
};
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1120
|
+
const getPickDescription$8 = pick => {
|
|
1121
|
+
const {
|
|
1122
|
+
provider
|
|
1123
|
+
} = state$a;
|
|
1124
|
+
// @ts-ignore
|
|
1125
|
+
if (provider.getPickDescription) {
|
|
1126
|
+
// @ts-ignore
|
|
1127
|
+
return provider.getPickDescription(pick);
|
|
1225
1128
|
}
|
|
1226
|
-
|
|
1227
|
-
const absolutePath = `${workspace}/${pick}`;
|
|
1228
|
-
await openUri(absolutePath);
|
|
1229
|
-
return {
|
|
1230
|
-
command: Hide
|
|
1231
|
-
};
|
|
1232
|
-
};
|
|
1233
|
-
const getFilterValue$9 = value => {
|
|
1234
|
-
return value;
|
|
1235
|
-
};
|
|
1236
|
-
const getPickFilterValue$7 = pick => {
|
|
1237
|
-
if (typeof pick === 'object') {
|
|
1238
|
-
pick = pick.pick;
|
|
1239
|
-
}
|
|
1240
|
-
return pick;
|
|
1241
|
-
};
|
|
1242
|
-
const getPickLabel$6 = pick => {
|
|
1243
|
-
if (typeof pick === 'object') {
|
|
1244
|
-
pick = pick.pick;
|
|
1245
|
-
}
|
|
1246
|
-
const baseName = pathBaseName(pick);
|
|
1247
|
-
return baseName;
|
|
1129
|
+
return '';
|
|
1248
1130
|
};
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
return
|
|
1131
|
+
const getPickLabel$8 = pick => {
|
|
1132
|
+
const {
|
|
1133
|
+
provider
|
|
1134
|
+
} = state$a;
|
|
1135
|
+
// @ts-ignore
|
|
1136
|
+
return provider.getPickLabel(pick);
|
|
1255
1137
|
};
|
|
1256
|
-
const getPickIcon$
|
|
1257
|
-
|
|
1138
|
+
const getPickIcon$8 = pick => {
|
|
1139
|
+
const {
|
|
1140
|
+
provider
|
|
1141
|
+
} = state$a;
|
|
1142
|
+
// @ts-ignore
|
|
1143
|
+
return provider.getPickIcon(pick);
|
|
1258
1144
|
};
|
|
1259
1145
|
const getPickFileIcon$2 = pick => {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1146
|
+
const {
|
|
1147
|
+
provider
|
|
1148
|
+
} = state$a;
|
|
1149
|
+
// @ts-ignore
|
|
1150
|
+
if (provider.getPickFileIcon) {
|
|
1151
|
+
// @ts-ignore
|
|
1152
|
+
return provider.getPickFileIcon(pick);
|
|
1265
1153
|
}
|
|
1266
|
-
const baseName = pathBaseName(pick);
|
|
1267
|
-
return {
|
|
1268
|
-
type: File$2,
|
|
1269
|
-
name: baseName,
|
|
1270
|
-
path: pick
|
|
1271
|
-
};
|
|
1272
|
-
};
|
|
1273
|
-
const isPrepared$6 = () => {
|
|
1274
|
-
const workspace = '';
|
|
1275
|
-
// TODO protocol should always be defined. For files it should use file protocol
|
|
1276
|
-
const protocol = getProtocol(workspace);
|
|
1277
|
-
return !protocol;
|
|
1278
|
-
};
|
|
1279
|
-
const getVisibleItems$9 = (files, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
1280
|
-
const visibleItems = files.map((item, i) => {
|
|
1281
|
-
const pick = item.pick;
|
|
1282
|
-
const label = getPickLabel$6(pick);
|
|
1283
|
-
const description = getPickDescription$6(pick);
|
|
1284
|
-
const icon = getPickIcon$6();
|
|
1285
|
-
const fileIcon = icons[i];
|
|
1286
|
-
return {
|
|
1287
|
-
label,
|
|
1288
|
-
description,
|
|
1289
|
-
icon,
|
|
1290
|
-
fileIcon,
|
|
1291
|
-
posInSet: minLineY + i + 1,
|
|
1292
|
-
setSize,
|
|
1293
|
-
isActive: i === focusedIndex,
|
|
1294
|
-
matches: item.matches
|
|
1295
|
-
};
|
|
1296
|
-
});
|
|
1297
|
-
return visibleItems;
|
|
1298
|
-
};
|
|
1299
|
-
|
|
1300
|
-
const QuickPickEntriesFile = {
|
|
1301
|
-
__proto__: null,
|
|
1302
|
-
getFilterValue: getFilterValue$9,
|
|
1303
|
-
getLabel: getLabel$4,
|
|
1304
|
-
getNoResults: getNoResults$9,
|
|
1305
|
-
getPickDescription: getPickDescription$6,
|
|
1306
|
-
getPickFileIcon: getPickFileIcon$2,
|
|
1307
|
-
getPickFilterValue: getPickFilterValue$7,
|
|
1308
|
-
getPickIcon: getPickIcon$6,
|
|
1309
|
-
getPickLabel: getPickLabel$6,
|
|
1310
|
-
getPicks: getPicks$9,
|
|
1311
|
-
getPlaceholder: getPlaceholder$9,
|
|
1312
|
-
getVisibleItems: getVisibleItems$9,
|
|
1313
|
-
isPrepared: isPrepared$6,
|
|
1314
|
-
name: name$9,
|
|
1315
|
-
selectPick: selectPick$9
|
|
1316
|
-
};
|
|
1317
|
-
|
|
1318
|
-
const execute = async (method, ...params) => {
|
|
1319
|
-
// TODO
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
|
-
const name$8 = 'goToLine';
|
|
1323
|
-
const getPlaceholder$8 = () => {
|
|
1324
|
-
return '';
|
|
1325
|
-
};
|
|
1326
|
-
const getHelpEntries$3 = () => {
|
|
1327
|
-
return [];
|
|
1328
|
-
};
|
|
1329
|
-
const getNoResults$8 = () => {
|
|
1330
1154
|
return undefined;
|
|
1331
1155
|
};
|
|
1332
|
-
const
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
label: '5'
|
|
1343
|
-
}, {
|
|
1344
|
-
label: '6'
|
|
1345
|
-
}];
|
|
1346
|
-
return picks;
|
|
1347
|
-
};
|
|
1348
|
-
const selectPick$8 = async item => {
|
|
1349
|
-
const rowIndex = Number.parseInt(item.label);
|
|
1350
|
-
const position = {
|
|
1351
|
-
rowIndex,
|
|
1352
|
-
columnIndex: 5
|
|
1353
|
-
};
|
|
1354
|
-
await execute(/* EditorSetCursor.editorSetCursor */'TODO', /* position */position);
|
|
1355
|
-
// TODO put cursor onto that line
|
|
1356
|
-
return {
|
|
1357
|
-
command: Hide
|
|
1358
|
-
};
|
|
1359
|
-
};
|
|
1360
|
-
const getFilterValue$8 = value => {
|
|
1361
|
-
return value;
|
|
1156
|
+
const isPrepared$8 = () => {
|
|
1157
|
+
const {
|
|
1158
|
+
provider
|
|
1159
|
+
} = state$a;
|
|
1160
|
+
// @ts-ignore
|
|
1161
|
+
if (provider.isPrepared) {
|
|
1162
|
+
// @ts-ignore
|
|
1163
|
+
return provider.isPrepared();
|
|
1164
|
+
}
|
|
1165
|
+
return false;
|
|
1362
1166
|
};
|
|
1363
1167
|
const getVisibleItems$8 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1366
|
-
fileIcon: '',
|
|
1367
|
-
icon: '',
|
|
1368
|
-
isActive: index + minLineY === focusedIndex,
|
|
1369
|
-
label: pick.label,
|
|
1370
|
-
matches: [],
|
|
1371
|
-
posInSet: index + minLineY + 1,
|
|
1372
|
-
setSize
|
|
1373
|
-
}));
|
|
1168
|
+
const items = picks.map(pick => pick.pick);
|
|
1169
|
+
const visibleItems = state$a.provider.getVisibleItems(items, minLineY, maxLineY, focusedIndex, setSize, icons);
|
|
1374
1170
|
return visibleItems;
|
|
1375
1171
|
};
|
|
1376
1172
|
|
|
1377
|
-
|
|
1173
|
+
// provider
|
|
1174
|
+
// - create
|
|
1175
|
+
// - loadcontent
|
|
1176
|
+
// - filter
|
|
1177
|
+
// - getVisible
|
|
1178
|
+
|
|
1179
|
+
// matches could be in loadcontent or getVisible
|
|
1180
|
+
|
|
1181
|
+
const QuickPickEntriesEverything = {
|
|
1378
1182
|
__proto__: null,
|
|
1379
1183
|
getFilterValue: getFilterValue$8,
|
|
1380
|
-
|
|
1184
|
+
getLabel: getLabel$5,
|
|
1381
1185
|
getNoResults: getNoResults$8,
|
|
1186
|
+
getPickDescription: getPickDescription$8,
|
|
1187
|
+
getPickFileIcon: getPickFileIcon$2,
|
|
1188
|
+
getPickFilterValue: getPickFilterValue$8,
|
|
1189
|
+
getPickIcon: getPickIcon$8,
|
|
1190
|
+
getPickLabel: getPickLabel$8,
|
|
1382
1191
|
getPicks: getPicks$8,
|
|
1383
1192
|
getPlaceholder: getPlaceholder$8,
|
|
1384
1193
|
getVisibleItems: getVisibleItems$8,
|
|
1194
|
+
isPrepared: isPrepared$8,
|
|
1385
1195
|
name: name$8,
|
|
1386
|
-
|
|
1196
|
+
openCommandPalette,
|
|
1197
|
+
openView,
|
|
1198
|
+
selectPick: selectPick$8,
|
|
1199
|
+
state: state$a
|
|
1387
1200
|
};
|
|
1388
1201
|
|
|
1389
|
-
const
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const
|
|
1202
|
+
const Default$1 = 0;
|
|
1203
|
+
const Finished = 2;
|
|
1204
|
+
|
|
1205
|
+
const create$2 = () => {
|
|
1206
|
+
const states = Object.create(null);
|
|
1394
1207
|
return {
|
|
1395
|
-
|
|
1208
|
+
get(uid) {
|
|
1209
|
+
return states[uid];
|
|
1210
|
+
},
|
|
1211
|
+
set(uid, oldState, newState) {
|
|
1212
|
+
states[uid] = {
|
|
1213
|
+
oldState,
|
|
1214
|
+
newState
|
|
1215
|
+
};
|
|
1216
|
+
},
|
|
1217
|
+
remove(uid) {
|
|
1218
|
+
delete states[uid];
|
|
1219
|
+
}
|
|
1396
1220
|
};
|
|
1397
1221
|
};
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
const
|
|
1222
|
+
|
|
1223
|
+
const {
|
|
1224
|
+
get,
|
|
1225
|
+
set,
|
|
1226
|
+
remove
|
|
1227
|
+
} = create$2();
|
|
1228
|
+
|
|
1229
|
+
const create$1 = ({
|
|
1230
|
+
itemHeight,
|
|
1231
|
+
headerHeight = 0,
|
|
1232
|
+
minimumSliderSize = 20
|
|
1233
|
+
}) => {
|
|
1406
1234
|
return {
|
|
1407
|
-
|
|
1235
|
+
deltaY: 0,
|
|
1236
|
+
minLineY: 0,
|
|
1237
|
+
maxLineY: 0,
|
|
1238
|
+
finalDeltaY: 0,
|
|
1239
|
+
itemHeight,
|
|
1240
|
+
headerHeight,
|
|
1241
|
+
items: [],
|
|
1242
|
+
minimumSliderSize,
|
|
1243
|
+
focusedIndex: -1,
|
|
1244
|
+
touchOffsetY: 0,
|
|
1245
|
+
touchTimeStamp: 0,
|
|
1246
|
+
touchDifference: 0,
|
|
1247
|
+
scrollBarHeight: 0,
|
|
1248
|
+
scrollBarActive: false
|
|
1408
1249
|
};
|
|
1409
1250
|
};
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
return '';
|
|
1416
|
-
};
|
|
1417
|
-
const isPrepared$5 = () => {
|
|
1418
|
-
return false;
|
|
1419
|
-
};
|
|
1420
|
-
const getPickFilterValue$6 = value => {
|
|
1421
|
-
return value;
|
|
1251
|
+
const getListHeight = (height, headerHeight) => {
|
|
1252
|
+
if (headerHeight) {
|
|
1253
|
+
return height - headerHeight;
|
|
1254
|
+
}
|
|
1255
|
+
return headerHeight;
|
|
1422
1256
|
};
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1257
|
+
const setDeltaY = (state, deltaY) => {
|
|
1258
|
+
object(state);
|
|
1259
|
+
number(deltaY);
|
|
1260
|
+
const {
|
|
1261
|
+
itemHeight,
|
|
1262
|
+
items,
|
|
1263
|
+
height,
|
|
1264
|
+
headerHeight
|
|
1265
|
+
} = state;
|
|
1266
|
+
const listHeight = getListHeight(height, headerHeight);
|
|
1267
|
+
const itemsLength = items.length;
|
|
1268
|
+
const finalDeltaY = itemsLength * itemHeight - listHeight;
|
|
1269
|
+
if (deltaY < 0) {
|
|
1270
|
+
deltaY = 0;
|
|
1271
|
+
} else if (deltaY > finalDeltaY) {
|
|
1272
|
+
deltaY = Math.max(finalDeltaY, 0);
|
|
1273
|
+
}
|
|
1274
|
+
if (state.deltaY === deltaY) {
|
|
1275
|
+
return state;
|
|
1276
|
+
}
|
|
1277
|
+
const minLineY = Math.round(deltaY / itemHeight);
|
|
1278
|
+
const maxLineY = minLineY + Math.round(listHeight / itemHeight);
|
|
1279
|
+
number(minLineY);
|
|
1280
|
+
number(maxLineY);
|
|
1281
|
+
return {
|
|
1282
|
+
...state,
|
|
1283
|
+
deltaY,
|
|
1284
|
+
minLineY,
|
|
1285
|
+
maxLineY
|
|
1286
|
+
};
|
|
1425
1287
|
};
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1288
|
+
const handleWheel = (state, deltaMode, deltaY) => {
|
|
1289
|
+
object(state);
|
|
1290
|
+
number(deltaMode);
|
|
1291
|
+
number(deltaY);
|
|
1292
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
1428
1293
|
};
|
|
1429
1294
|
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1295
|
+
const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
|
|
1296
|
+
const state = {
|
|
1297
|
+
uid,
|
|
1298
|
+
icons: [],
|
|
1299
|
+
state: Default$1,
|
|
1300
|
+
picks: [],
|
|
1301
|
+
recentPicks: [],
|
|
1302
|
+
recentPickIds: new Map(),
|
|
1303
|
+
// TODO use object.create(null) instead
|
|
1304
|
+
versionId: 0,
|
|
1305
|
+
provider: QuickPickEntriesEverything,
|
|
1306
|
+
// TODO make this dynamic again
|
|
1307
|
+
warned: [],
|
|
1308
|
+
maxVisibleItems: 10,
|
|
1309
|
+
uri,
|
|
1310
|
+
cursorOffset: 0,
|
|
1311
|
+
height: 300,
|
|
1312
|
+
top: 50,
|
|
1313
|
+
width: 600,
|
|
1314
|
+
...create$1({
|
|
1315
|
+
itemHeight: listItemHeight,
|
|
1316
|
+
headerHeight: 30,
|
|
1317
|
+
minimumSliderSize: minimumSliderSize
|
|
1318
|
+
}),
|
|
1319
|
+
inputSource: User,
|
|
1320
|
+
args,
|
|
1321
|
+
focused: false,
|
|
1322
|
+
platform,
|
|
1323
|
+
value: '',
|
|
1324
|
+
fileIconCache: Object.create(null)
|
|
1325
|
+
};
|
|
1326
|
+
set(uid, state, state);
|
|
1445
1327
|
};
|
|
1446
1328
|
|
|
1447
|
-
|
|
1329
|
+
const RenderItems = 1;
|
|
1330
|
+
const RenderFocus = 2;
|
|
1331
|
+
const RenderValue = 3;
|
|
1332
|
+
const RenderCursorOffset = 7;
|
|
1333
|
+
const RenderFocusedIndex = 8;
|
|
1334
|
+
const Height = 9;
|
|
1448
1335
|
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
const getHelpEntries$2 = () => {
|
|
1453
|
-
return undefined;
|
|
1454
|
-
};
|
|
1455
|
-
const getPicks$6 = async () => {
|
|
1456
|
-
// const views = ViewService.getViews()
|
|
1457
|
-
// const picks = views.map(toPick)
|
|
1458
|
-
// return picks
|
|
1459
|
-
return [];
|
|
1460
|
-
};
|
|
1461
|
-
const selectPick$6 = async item => {
|
|
1462
|
-
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
1463
|
-
// return {
|
|
1464
|
-
// command: QuickPickReturnValue.Hide,
|
|
1465
|
-
// }
|
|
1466
|
-
};
|
|
1467
|
-
const getFilterValue$6 = value => {
|
|
1468
|
-
return value;
|
|
1469
|
-
};
|
|
1470
|
-
const getPickFilterValue$5 = value => {
|
|
1471
|
-
return value;
|
|
1472
|
-
};
|
|
1473
|
-
const getPickLabel$4 = value => {
|
|
1474
|
-
return value;
|
|
1475
|
-
};
|
|
1476
|
-
const getPickIcon$4 = value => {
|
|
1477
|
-
return '';
|
|
1478
|
-
};
|
|
1479
|
-
const state$5 = {};
|
|
1480
|
-
const getNoResults$6 = () => {
|
|
1481
|
-
return '';
|
|
1482
|
-
};
|
|
1483
|
-
const name$6 = '';
|
|
1484
|
-
const isPrepared$4 = () => {
|
|
1485
|
-
return true;
|
|
1486
|
-
};
|
|
1487
|
-
const getPickDescription$4 = () => {
|
|
1488
|
-
return '';
|
|
1489
|
-
};
|
|
1490
|
-
const getVisibleItems$6 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
|
|
1491
|
-
const visibleItems = picks.map((pick, index) => ({
|
|
1492
|
-
description: getPickDescription$4(),
|
|
1493
|
-
fileIcon: '',
|
|
1494
|
-
icon: getPickIcon$4(),
|
|
1495
|
-
isActive: index + minLineY === focusedIndex,
|
|
1496
|
-
label: getPickLabel$4(pick),
|
|
1497
|
-
matches: [],
|
|
1498
|
-
posInSet: index + minLineY + 1,
|
|
1499
|
-
setSize
|
|
1500
|
-
}));
|
|
1501
|
-
return visibleItems;
|
|
1336
|
+
const diffType$4 = RenderFocus;
|
|
1337
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1338
|
+
return oldState.focused === newState.focused;
|
|
1502
1339
|
};
|
|
1503
1340
|
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
getHelpEntries: getHelpEntries$2,
|
|
1508
|
-
getNoResults: getNoResults$6,
|
|
1509
|
-
getPickDescription: getPickDescription$4,
|
|
1510
|
-
getPickFilterValue: getPickFilterValue$5,
|
|
1511
|
-
getPickIcon: getPickIcon$4,
|
|
1512
|
-
getPickLabel: getPickLabel$4,
|
|
1513
|
-
getPicks: getPicks$6,
|
|
1514
|
-
getPlaceholder: getPlaceholder$6,
|
|
1515
|
-
getVisibleItems: getVisibleItems$6,
|
|
1516
|
-
isPrepared: isPrepared$4,
|
|
1517
|
-
name: name$6,
|
|
1518
|
-
selectPick: selectPick$6,
|
|
1519
|
-
state: state$5
|
|
1341
|
+
const diffType$3 = RenderFocusedIndex;
|
|
1342
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1343
|
+
return oldState.focusedIndex === newState.focusedIndex;
|
|
1520
1344
|
};
|
|
1521
1345
|
|
|
1522
|
-
const
|
|
1523
|
-
const
|
|
1524
|
-
return
|
|
1525
|
-
};
|
|
1526
|
-
const getNoResults$5 = () => {
|
|
1527
|
-
return {
|
|
1528
|
-
label: noWorkspaceSymbolsFound()
|
|
1529
|
-
};
|
|
1530
|
-
};
|
|
1531
|
-
const getPicks$5 = async () => {
|
|
1532
|
-
const picks = [];
|
|
1533
|
-
return picks;
|
|
1534
|
-
};
|
|
1535
|
-
const selectPick$5 = async item => {
|
|
1536
|
-
return {
|
|
1537
|
-
command: Hide
|
|
1538
|
-
};
|
|
1539
|
-
};
|
|
1540
|
-
const getFilterValue$5 = value => {
|
|
1541
|
-
return value;
|
|
1346
|
+
const diffType$2 = Height;
|
|
1347
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1348
|
+
return oldState.items.length === newState.items.length;
|
|
1542
1349
|
};
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
icon: '',
|
|
1548
|
-
isActive: index + minLineY === focusedIndex,
|
|
1549
|
-
label: pick.label || '',
|
|
1550
|
-
matches: [],
|
|
1551
|
-
posInSet: index + minLineY + 1,
|
|
1552
|
-
setSize
|
|
1553
|
-
}));
|
|
1554
|
-
return visibleItems;
|
|
1350
|
+
|
|
1351
|
+
const diffType$1 = RenderItems;
|
|
1352
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1353
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
1555
1354
|
};
|
|
1556
1355
|
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
getNoResults: getNoResults$5,
|
|
1561
|
-
getPicks: getPicks$5,
|
|
1562
|
-
getPlaceholder: getPlaceholder$5,
|
|
1563
|
-
getVisibleItems: getVisibleItems$5,
|
|
1564
|
-
name: name$5,
|
|
1565
|
-
selectPick: selectPick$5
|
|
1356
|
+
const diffType = RenderValue;
|
|
1357
|
+
const isEqual = (oldState, newState) => {
|
|
1358
|
+
return newState.inputSource === User || oldState.value === newState.value;
|
|
1566
1359
|
};
|
|
1567
1360
|
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
return QuickPickEntriesWorkspaceSymbol;
|
|
1579
|
-
case GoToLine:
|
|
1580
|
-
return QuickPickEntriesGoToLine;
|
|
1581
|
-
case View$1:
|
|
1582
|
-
return QuickPickEntriesView;
|
|
1583
|
-
default:
|
|
1584
|
-
return QuickPickEntriesFile;
|
|
1361
|
+
const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
|
|
1362
|
+
const numbers = [diffType$2, diffType$1, diffType, diffType$3, diffType$4];
|
|
1363
|
+
|
|
1364
|
+
const diff = (oldState, newState) => {
|
|
1365
|
+
const diffResult = [];
|
|
1366
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1367
|
+
const fn = modules[i];
|
|
1368
|
+
if (!fn(oldState, newState)) {
|
|
1369
|
+
diffResult.push(numbers[i]);
|
|
1370
|
+
}
|
|
1585
1371
|
}
|
|
1372
|
+
return diffResult;
|
|
1586
1373
|
};
|
|
1587
1374
|
|
|
1588
|
-
const
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
return
|
|
1594
|
-
};
|
|
1595
|
-
const getPicks$4 = async value => {
|
|
1596
|
-
return [];
|
|
1597
|
-
};
|
|
1598
|
-
const selectPick$4 = async item => {
|
|
1599
|
-
return {
|
|
1600
|
-
command: Hide
|
|
1601
|
-
};
|
|
1602
|
-
};
|
|
1603
|
-
const getFilterValue$4 = value => {
|
|
1604
|
-
return value;
|
|
1605
|
-
};
|
|
1606
|
-
const getPickFilterValue$4 = pick => {
|
|
1607
|
-
return pick;
|
|
1608
|
-
};
|
|
1609
|
-
const getVisibleItems$4 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
1610
|
-
return [];
|
|
1375
|
+
const diff2 = uid => {
|
|
1376
|
+
const {
|
|
1377
|
+
oldState,
|
|
1378
|
+
newState
|
|
1379
|
+
} = get(uid);
|
|
1380
|
+
return diff(oldState, newState);
|
|
1611
1381
|
};
|
|
1612
1382
|
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1615
|
-
getFilterValue: getFilterValue$4,
|
|
1616
|
-
getNoResults: getNoResults$4,
|
|
1617
|
-
getPickFilterValue: getPickFilterValue$4,
|
|
1618
|
-
getPicks: getPicks$4,
|
|
1619
|
-
getPlaceholder: getPlaceholder$4,
|
|
1620
|
-
getVisibleItems: getVisibleItems$4,
|
|
1621
|
-
name: name$4,
|
|
1622
|
-
selectPick: selectPick$4
|
|
1383
|
+
const dispose = uid => {
|
|
1384
|
+
remove(uid);
|
|
1623
1385
|
};
|
|
1624
1386
|
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
provider: QuickPickNoop,
|
|
1630
|
-
prefix: 'string-that-should-never-match-another-string'
|
|
1387
|
+
const emptyDirent = {
|
|
1388
|
+
name: '',
|
|
1389
|
+
path: '',
|
|
1390
|
+
type: 0
|
|
1631
1391
|
};
|
|
1632
1392
|
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
*/
|
|
1636
|
-
const name$3 = 'everything';
|
|
1637
|
-
const getPlaceholder$3 = () => {
|
|
1638
|
-
return state$4.provider.getPlaceholder();
|
|
1639
|
-
};
|
|
1640
|
-
const getLabel$3 = () => {
|
|
1641
|
-
return '';
|
|
1642
|
-
};
|
|
1643
|
-
const getNoResults$3 = () => {
|
|
1644
|
-
return state$4.provider.getNoResults();
|
|
1393
|
+
const getIconsCached = (paths, fileIconCache) => {
|
|
1394
|
+
return paths.map(path => fileIconCache[path]);
|
|
1645
1395
|
};
|
|
1646
|
-
const getPicks$3 = async value => {
|
|
1647
|
-
const prefix = getQuickPickPrefix(value);
|
|
1648
1396
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1397
|
+
const Directory = 3;
|
|
1398
|
+
const File$1 = 7;
|
|
1399
|
+
|
|
1400
|
+
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1401
|
+
const missingRequests = [];
|
|
1402
|
+
for (const dirent of dirents) {
|
|
1403
|
+
if (!(dirent.path in fileIconCache)) {
|
|
1404
|
+
missingRequests.push({
|
|
1405
|
+
type: File$1,
|
|
1406
|
+
name: dirent.name,
|
|
1407
|
+
path: dirent.path
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1653
1410
|
}
|
|
1654
|
-
|
|
1655
|
-
const slicedValue = value.slice(prefix.length).trimStart();
|
|
1656
|
-
const picks = await state$4.provider.getPicks(slicedValue);
|
|
1657
|
-
return picks;
|
|
1658
|
-
};
|
|
1659
|
-
const selectPick$3 = item => {
|
|
1660
|
-
const {
|
|
1661
|
-
provider
|
|
1662
|
-
} = state$4;
|
|
1663
|
-
return provider.selectPick(item);
|
|
1411
|
+
return missingRequests;
|
|
1664
1412
|
};
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1413
|
+
|
|
1414
|
+
const requestFileIcons = async requests => {
|
|
1415
|
+
const promises = requests.map(request => {
|
|
1416
|
+
if (!request.name) {
|
|
1417
|
+
return '';
|
|
1418
|
+
}
|
|
1419
|
+
return request.type === File$1 ? invoke$1('IconTheme.getFileIcon', {
|
|
1420
|
+
name: request.name
|
|
1421
|
+
}) : invoke$1('IconTheme.getFolderIcon', {
|
|
1422
|
+
name: request.name
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
return Promise.all(promises);
|
|
1670
1426
|
};
|
|
1671
|
-
|
|
1672
|
-
|
|
1427
|
+
|
|
1428
|
+
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
1429
|
+
if (missingRequests.length === 0) {
|
|
1430
|
+
return iconCache;
|
|
1431
|
+
}
|
|
1432
|
+
const newFileIconCache = {
|
|
1433
|
+
...iconCache
|
|
1434
|
+
};
|
|
1435
|
+
for (let i = 0; i < missingRequests.length; i++) {
|
|
1436
|
+
const request = missingRequests[i];
|
|
1437
|
+
const icon = newIcons[i];
|
|
1438
|
+
newFileIconCache[request.path] = icon;
|
|
1439
|
+
}
|
|
1440
|
+
return newFileIconCache;
|
|
1673
1441
|
};
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1442
|
+
|
|
1443
|
+
const getQuickPickFileIcons = async (provider, items, fileIconCache) => {
|
|
1444
|
+
const dirents = items.map(item => {
|
|
1445
|
+
const dirent = provider.getPickFileIcon?.(item) || emptyDirent;
|
|
1446
|
+
return dirent;
|
|
1447
|
+
});
|
|
1448
|
+
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
1449
|
+
const newIcons = await requestFileIcons(missingRequests);
|
|
1450
|
+
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1451
|
+
const paths = dirents.map(file => file.path);
|
|
1452
|
+
const icons = getIconsCached(paths, newFileIconCache);
|
|
1453
|
+
return {
|
|
1454
|
+
icons,
|
|
1455
|
+
newFileIconCache
|
|
1456
|
+
};
|
|
1679
1457
|
};
|
|
1680
|
-
|
|
1458
|
+
|
|
1459
|
+
const focusIndex = async (state, index) => {
|
|
1681
1460
|
const {
|
|
1682
|
-
provider
|
|
1683
|
-
|
|
1461
|
+
provider,
|
|
1462
|
+
maxVisibleItems,
|
|
1463
|
+
items,
|
|
1464
|
+
minLineY,
|
|
1465
|
+
maxLineY,
|
|
1466
|
+
fileIconCache
|
|
1467
|
+
} = state;
|
|
1468
|
+
// TODO get types working
|
|
1684
1469
|
// @ts-ignore
|
|
1685
|
-
if (provider.
|
|
1470
|
+
if (provider.focusPick) {
|
|
1686
1471
|
// @ts-ignore
|
|
1687
|
-
|
|
1472
|
+
await provider.focusPick(items[index].pick);
|
|
1688
1473
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
const
|
|
1474
|
+
if (index < minLineY + 1) {
|
|
1475
|
+
const minLineY = index;
|
|
1476
|
+
const maxLineY = Math.min(index + maxVisibleItems, items.length - 1);
|
|
1477
|
+
const sliced = items.slice(minLineY, maxLineY);
|
|
1478
|
+
const {
|
|
1479
|
+
newFileIconCache,
|
|
1480
|
+
icons
|
|
1481
|
+
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
1482
|
+
|
|
1483
|
+
// TODO need to scroll up
|
|
1484
|
+
return {
|
|
1485
|
+
...state,
|
|
1486
|
+
minLineY,
|
|
1487
|
+
maxLineY,
|
|
1488
|
+
focusedIndex: index,
|
|
1489
|
+
icons,
|
|
1490
|
+
fileIconCache: newFileIconCache
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
if (index >= maxLineY - 1) {
|
|
1494
|
+
// TODO need to scroll down
|
|
1495
|
+
const maxLineY = index + 1;
|
|
1496
|
+
const minLineY = Math.max(maxLineY - maxVisibleItems, 0);
|
|
1497
|
+
const sliced = items.slice(minLineY, maxLineY);
|
|
1498
|
+
const {
|
|
1499
|
+
newFileIconCache,
|
|
1500
|
+
icons
|
|
1501
|
+
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
1502
|
+
return {
|
|
1503
|
+
...state,
|
|
1504
|
+
minLineY,
|
|
1505
|
+
maxLineY,
|
|
1506
|
+
focusedIndex: index,
|
|
1507
|
+
fileIconCache: newFileIconCache,
|
|
1508
|
+
icons
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
const sliced = items.slice(minLineY, maxLineY);
|
|
1692
1512
|
const {
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
return
|
|
1513
|
+
newFileIconCache,
|
|
1514
|
+
icons
|
|
1515
|
+
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
1516
|
+
return {
|
|
1517
|
+
...state,
|
|
1518
|
+
focusedIndex: index,
|
|
1519
|
+
fileIconCache: newFileIconCache,
|
|
1520
|
+
icons
|
|
1521
|
+
};
|
|
1697
1522
|
};
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
} = state$4;
|
|
1702
|
-
// @ts-ignore
|
|
1703
|
-
return provider.getPickIcon(pick);
|
|
1523
|
+
|
|
1524
|
+
const first = () => {
|
|
1525
|
+
return 0;
|
|
1704
1526
|
};
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
provider
|
|
1708
|
-
} = state$4;
|
|
1709
|
-
// @ts-ignore
|
|
1710
|
-
if (provider.getPickFileIcon) {
|
|
1711
|
-
// @ts-ignore
|
|
1712
|
-
return provider.getPickFileIcon(pick);
|
|
1713
|
-
}
|
|
1714
|
-
return undefined;
|
|
1527
|
+
const last = items => {
|
|
1528
|
+
return items.length - 1;
|
|
1715
1529
|
};
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1718
|
-
provider
|
|
1719
|
-
} = state$4;
|
|
1720
|
-
// @ts-ignore
|
|
1721
|
-
if (provider.isPrepared) {
|
|
1722
|
-
// @ts-ignore
|
|
1723
|
-
return provider.isPrepared();
|
|
1724
|
-
}
|
|
1725
|
-
return false;
|
|
1530
|
+
const next = (items, index) => {
|
|
1531
|
+
return (index + 1) % items.length;
|
|
1726
1532
|
};
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1729
|
-
const visibleItems = state$4.provider.getVisibleItems(items, minLineY, maxLineY, focusedIndex, setSize, icons);
|
|
1730
|
-
return visibleItems;
|
|
1533
|
+
const previous = (items, index) => {
|
|
1534
|
+
return index === 0 ? items.length - 1 : index - 1;
|
|
1731
1535
|
};
|
|
1732
1536
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
// - loadcontent
|
|
1736
|
-
// - filter
|
|
1737
|
-
// - getVisible
|
|
1738
|
-
|
|
1739
|
-
// matches could be in loadcontent or getVisible
|
|
1740
|
-
|
|
1741
|
-
const QuickPickEntriesEverything = {
|
|
1742
|
-
__proto__: null,
|
|
1743
|
-
getFilterValue: getFilterValue$3,
|
|
1744
|
-
getLabel: getLabel$3,
|
|
1745
|
-
getNoResults: getNoResults$3,
|
|
1746
|
-
getPickDescription: getPickDescription$3,
|
|
1747
|
-
getPickFileIcon: getPickFileIcon$1,
|
|
1748
|
-
getPickFilterValue: getPickFilterValue$3,
|
|
1749
|
-
getPickIcon: getPickIcon$3,
|
|
1750
|
-
getPickLabel: getPickLabel$3,
|
|
1751
|
-
getPicks: getPicks$3,
|
|
1752
|
-
getPlaceholder: getPlaceholder$3,
|
|
1753
|
-
getVisibleItems: getVisibleItems$3,
|
|
1754
|
-
isPrepared: isPrepared$3,
|
|
1755
|
-
name: name$3,
|
|
1756
|
-
openCommandPalette,
|
|
1757
|
-
openView,
|
|
1758
|
-
selectPick: selectPick$3,
|
|
1759
|
-
state: state$4
|
|
1537
|
+
const focusFirst = state => {
|
|
1538
|
+
return focusIndex(state, first());
|
|
1760
1539
|
};
|
|
1761
1540
|
|
|
1762
|
-
const
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
return {
|
|
1768
|
-
get(uid) {
|
|
1769
|
-
return states[uid];
|
|
1770
|
-
},
|
|
1771
|
-
set(uid, oldState, newState) {
|
|
1772
|
-
states[uid] = {
|
|
1773
|
-
oldState,
|
|
1774
|
-
newState
|
|
1775
|
-
};
|
|
1776
|
-
},
|
|
1777
|
-
remove(uid) {
|
|
1778
|
-
delete states[uid];
|
|
1779
|
-
}
|
|
1780
|
-
};
|
|
1541
|
+
const focusLast = state => {
|
|
1542
|
+
const {
|
|
1543
|
+
items
|
|
1544
|
+
} = state;
|
|
1545
|
+
return focusIndex(state, last(items));
|
|
1781
1546
|
};
|
|
1782
1547
|
|
|
1783
|
-
const {
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
} =
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
itemHeight,
|
|
1791
|
-
headerHeight = 0,
|
|
1792
|
-
minimumSliderSize = 20
|
|
1793
|
-
}) => {
|
|
1794
|
-
return {
|
|
1795
|
-
deltaY: 0,
|
|
1796
|
-
minLineY: 0,
|
|
1797
|
-
maxLineY: 0,
|
|
1798
|
-
finalDeltaY: 0,
|
|
1799
|
-
itemHeight,
|
|
1800
|
-
headerHeight,
|
|
1801
|
-
items: [],
|
|
1802
|
-
minimumSliderSize,
|
|
1803
|
-
focusedIndex: -1,
|
|
1804
|
-
touchOffsetY: 0,
|
|
1805
|
-
touchTimeStamp: 0,
|
|
1806
|
-
touchDifference: 0,
|
|
1807
|
-
scrollBarHeight: 0,
|
|
1808
|
-
scrollBarActive: false
|
|
1809
|
-
};
|
|
1810
|
-
};
|
|
1811
|
-
const getListHeight = (height, headerHeight) => {
|
|
1812
|
-
if (headerHeight) {
|
|
1813
|
-
return height - headerHeight;
|
|
1814
|
-
}
|
|
1815
|
-
return headerHeight;
|
|
1548
|
+
const focusNext = state => {
|
|
1549
|
+
const {
|
|
1550
|
+
items,
|
|
1551
|
+
focusedIndex
|
|
1552
|
+
} = state;
|
|
1553
|
+
const nextIndex = next(items, focusedIndex);
|
|
1554
|
+
return focusIndex(state, nextIndex);
|
|
1816
1555
|
};
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
number(deltaY);
|
|
1556
|
+
|
|
1557
|
+
const focusPrevious = state => {
|
|
1820
1558
|
const {
|
|
1821
|
-
itemHeight,
|
|
1822
1559
|
items,
|
|
1823
|
-
|
|
1824
|
-
headerHeight
|
|
1560
|
+
focusedIndex
|
|
1825
1561
|
} = state;
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1562
|
+
const previousIndex = previous(items, focusedIndex);
|
|
1563
|
+
return focusIndex(state, previousIndex);
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
const commandIds = ['close', 'dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'diff2', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
|
|
1567
|
+
|
|
1568
|
+
const getCommandIds = () => {
|
|
1569
|
+
return commandIds;
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
|
+
const Enter = 3;
|
|
1573
|
+
const Escape = 8;
|
|
1574
|
+
const PageUp = 10;
|
|
1575
|
+
const PageDown = 11;
|
|
1576
|
+
const UpArrow = 14;
|
|
1577
|
+
const DownArrow = 16;
|
|
1578
|
+
|
|
1579
|
+
const FocusQuickPickInput = 20;
|
|
1580
|
+
|
|
1581
|
+
const getKeyBindings = () => {
|
|
1582
|
+
return [{
|
|
1583
|
+
key: Escape,
|
|
1584
|
+
command: 'Viewlet.closeWidget',
|
|
1585
|
+
args: ['QuickPick'],
|
|
1586
|
+
when: FocusQuickPickInput
|
|
1587
|
+
}, {
|
|
1588
|
+
key: UpArrow,
|
|
1589
|
+
command: 'QuickPick.focusPrevious',
|
|
1590
|
+
when: FocusQuickPickInput
|
|
1591
|
+
}, {
|
|
1592
|
+
key: DownArrow,
|
|
1593
|
+
command: 'QuickPick.focusNext',
|
|
1594
|
+
when: FocusQuickPickInput
|
|
1595
|
+
}, {
|
|
1596
|
+
key: PageUp,
|
|
1597
|
+
command: 'QuickPick.focusFirst',
|
|
1598
|
+
when: FocusQuickPickInput
|
|
1599
|
+
}, {
|
|
1600
|
+
key: PageDown,
|
|
1601
|
+
command: 'QuickPick.focusLast',
|
|
1602
|
+
when: FocusQuickPickInput
|
|
1603
|
+
}, {
|
|
1604
|
+
key: Enter,
|
|
1605
|
+
command: 'QuickPick.selectCurrentIndex',
|
|
1606
|
+
when: FocusQuickPickInput
|
|
1607
|
+
}];
|
|
1608
|
+
};
|
|
1609
|
+
|
|
1610
|
+
const InsertText = 'insertText';
|
|
1611
|
+
const DeleteContentBackward = 'deleteContentBackward';
|
|
1612
|
+
const DeleteContentForward = 'deleteContentForward';
|
|
1613
|
+
const DeleteWordForward = 'deleteWordForward';
|
|
1614
|
+
const DeleteWordBackward = 'deleteWordBackward';
|
|
1615
|
+
const InsertLineBreak = 'insertLineBreak';
|
|
1616
|
+
const InsertCompositionText = 'insertCompositionText';
|
|
1617
|
+
const InsertFromPaste = 'insertFromPaste';
|
|
1618
|
+
|
|
1619
|
+
const RE_ALPHA_NUMERIC = /[a-z\d]/i;
|
|
1620
|
+
const isAlphaNumeric = character => {
|
|
1621
|
+
return RE_ALPHA_NUMERIC.test(character);
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
const getNewValueInsertText = (value, selectionStart, selectionEnd, data) => {
|
|
1625
|
+
if (selectionStart === value.length) {
|
|
1626
|
+
const newValue = value + data;
|
|
1627
|
+
return {
|
|
1628
|
+
newValue,
|
|
1629
|
+
cursorOffset: newValue.length
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
const before = value.slice(0, selectionStart);
|
|
1633
|
+
const after = value.slice(selectionEnd);
|
|
1634
|
+
const newValue = before + data + after;
|
|
1635
|
+
return {
|
|
1636
|
+
newValue,
|
|
1637
|
+
cursorOffset: selectionStart + data.length
|
|
1638
|
+
};
|
|
1639
|
+
};
|
|
1640
|
+
const getNewValueDeleteContentBackward = (value, selectionStart, selectionEnd, data) => {
|
|
1641
|
+
const after = value.slice(selectionEnd);
|
|
1642
|
+
if (selectionStart === selectionEnd) {
|
|
1643
|
+
const before = value.slice(0, selectionStart - 1);
|
|
1644
|
+
const newValue = before + after;
|
|
1645
|
+
return {
|
|
1646
|
+
newValue,
|
|
1647
|
+
cursorOffset: before.length
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
const before = value.slice(0, selectionStart);
|
|
1651
|
+
const newValue = before + after;
|
|
1652
|
+
return {
|
|
1653
|
+
newValue,
|
|
1654
|
+
cursorOffset: selectionStart
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
const getNewValueDeleteWordBackward = (value, selectionStart, selectionEnd, data) => {
|
|
1658
|
+
const after = value.slice(selectionEnd);
|
|
1659
|
+
if (selectionStart === selectionEnd) {
|
|
1660
|
+
let startIndex = Math.max(selectionStart - 1, 0);
|
|
1661
|
+
while (startIndex > 0 && isAlphaNumeric(value[startIndex])) {
|
|
1662
|
+
startIndex--;
|
|
1663
|
+
}
|
|
1664
|
+
const before = value.slice(0, startIndex);
|
|
1665
|
+
const newValue = before + after;
|
|
1666
|
+
return {
|
|
1667
|
+
newValue,
|
|
1668
|
+
cursorOffset: before.length
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
const before = value.slice(0, selectionStart);
|
|
1672
|
+
const newValue = before + after;
|
|
1673
|
+
return {
|
|
1674
|
+
newValue,
|
|
1675
|
+
cursorOffset: selectionStart
|
|
1676
|
+
};
|
|
1677
|
+
};
|
|
1678
|
+
const getNewValueDeleteContentForward = (value, selectionStart, selectionEnd, data) => {
|
|
1679
|
+
const before = value.slice(0, selectionStart);
|
|
1680
|
+
if (selectionStart === selectionEnd) {
|
|
1681
|
+
const after = value.slice(selectionEnd + 1);
|
|
1682
|
+
const newValue = before + after;
|
|
1683
|
+
return {
|
|
1684
|
+
newValue,
|
|
1685
|
+
cursorOffset: selectionStart
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
const after = value.slice(selectionEnd);
|
|
1689
|
+
const newValue = before + after;
|
|
1690
|
+
return {
|
|
1691
|
+
newValue,
|
|
1692
|
+
cursorOffset: selectionStart
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1695
|
+
const getNewValueDeleteWordForward = (value, selectionStart, selectionEnd, data) => {
|
|
1696
|
+
const before = value.slice(0, selectionStart);
|
|
1697
|
+
if (selectionStart === selectionEnd) {
|
|
1698
|
+
let startIndex = Math.min(selectionStart + 1, value.length - 1);
|
|
1699
|
+
while (startIndex < value.length && isAlphaNumeric(value[startIndex])) {
|
|
1700
|
+
startIndex++;
|
|
1701
|
+
}
|
|
1702
|
+
const after = value.slice(startIndex);
|
|
1703
|
+
const newValue = before + after;
|
|
1704
|
+
return {
|
|
1705
|
+
newValue,
|
|
1706
|
+
cursorOffset: before.length
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
const after = value.slice(selectionEnd);
|
|
1710
|
+
const newValue = before + after;
|
|
1711
|
+
return {
|
|
1712
|
+
newValue,
|
|
1713
|
+
cursorOffset: selectionStart
|
|
1714
|
+
};
|
|
1715
|
+
};
|
|
1716
|
+
const getNewValueInsertCompositionText = (value, selectionStart, selectionEnd, data) => {
|
|
1717
|
+
return getNewValueInsertText(value, selectionStart, selectionEnd, data);
|
|
1718
|
+
};
|
|
1719
|
+
const getNewValueInsertLineBreak = (value, selectionStart, selectionEnd, data) => {
|
|
1720
|
+
return {
|
|
1721
|
+
newValue: value,
|
|
1722
|
+
cursorOffset: selectionEnd
|
|
1723
|
+
};
|
|
1724
|
+
};
|
|
1725
|
+
const getNewValueFunction = inputType => {
|
|
1726
|
+
switch (inputType) {
|
|
1727
|
+
case InsertFromPaste:
|
|
1728
|
+
case InsertText:
|
|
1729
|
+
return getNewValueInsertText;
|
|
1730
|
+
case DeleteContentBackward:
|
|
1731
|
+
return getNewValueDeleteContentBackward;
|
|
1732
|
+
case DeleteContentForward:
|
|
1733
|
+
return getNewValueDeleteContentForward;
|
|
1734
|
+
case DeleteWordForward:
|
|
1735
|
+
return getNewValueDeleteWordForward;
|
|
1736
|
+
case DeleteWordBackward:
|
|
1737
|
+
return getNewValueDeleteWordBackward;
|
|
1738
|
+
case InsertLineBreak:
|
|
1739
|
+
return getNewValueInsertLineBreak;
|
|
1740
|
+
case InsertCompositionText:
|
|
1741
|
+
return getNewValueInsertCompositionText;
|
|
1742
|
+
default:
|
|
1743
|
+
throw new Error(`unsupported input type ${inputType}`);
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
|
|
1747
|
+
const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
|
|
1748
|
+
const fn = getNewValueFunction(inputType);
|
|
1749
|
+
return fn(value, selectionStart, selectionEnd, data);
|
|
1750
|
+
};
|
|
1751
|
+
|
|
1752
|
+
const emptyMatches = [];
|
|
1753
|
+
|
|
1754
|
+
const convertToPick = item => {
|
|
1755
|
+
return {
|
|
1756
|
+
pick: item,
|
|
1757
|
+
matches: emptyMatches
|
|
1758
|
+
};
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
const Diagonal = 1;
|
|
1762
|
+
const Left = 2;
|
|
1763
|
+
|
|
1764
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1765
|
+
|
|
1766
|
+
const createTable = size => {
|
|
1767
|
+
const table = [];
|
|
1768
|
+
for (let i = 0; i < size; i++) {
|
|
1769
|
+
const row = new Uint8Array(size);
|
|
1770
|
+
table.push(row);
|
|
1771
|
+
}
|
|
1772
|
+
return table;
|
|
1773
|
+
};
|
|
1774
|
+
const EmptyMatches = [];
|
|
1775
|
+
const Dash = '-';
|
|
1776
|
+
const Dot = '.';
|
|
1777
|
+
const EmptyString = '';
|
|
1778
|
+
const Space = ' ';
|
|
1779
|
+
const Underline = '_';
|
|
1780
|
+
const T = 't';
|
|
1781
|
+
const isLowerCase = char => {
|
|
1782
|
+
return char === char.toLowerCase();
|
|
1783
|
+
};
|
|
1784
|
+
const isUpperCase = char => {
|
|
1785
|
+
return char === char.toUpperCase();
|
|
1786
|
+
};
|
|
1787
|
+
|
|
1788
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1789
|
+
const isGap = (columnCharBefore, columnChar) => {
|
|
1790
|
+
switch (columnCharBefore) {
|
|
1791
|
+
case Dash:
|
|
1792
|
+
case Underline:
|
|
1793
|
+
case EmptyString:
|
|
1794
|
+
case T:
|
|
1795
|
+
case Space:
|
|
1796
|
+
case Dot:
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
|
|
1800
|
+
return true;
|
|
1801
|
+
}
|
|
1802
|
+
return false;
|
|
1803
|
+
};
|
|
1804
|
+
|
|
1805
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1806
|
+
const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
|
|
1807
|
+
if (rowCharLow !== columnCharLow) {
|
|
1808
|
+
return -1;
|
|
1809
|
+
}
|
|
1810
|
+
const isMatch = rowChar === columnChar;
|
|
1811
|
+
if (isMatch) {
|
|
1812
|
+
if (isDiagonalMatch) {
|
|
1813
|
+
return 8;
|
|
1814
|
+
}
|
|
1815
|
+
if (isGap(columnCharBefore, columnChar)) {
|
|
1816
|
+
return 8;
|
|
1817
|
+
}
|
|
1818
|
+
return 5;
|
|
1819
|
+
}
|
|
1820
|
+
if (isGap(columnCharBefore, columnChar)) {
|
|
1821
|
+
return 8;
|
|
1822
|
+
}
|
|
1823
|
+
return 5;
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1827
|
+
|
|
1828
|
+
const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
|
|
1829
|
+
while (patternPos < patternLen && wordPos < wordLen) {
|
|
1830
|
+
if (patternLow[patternPos] === wordLow[wordPos]) {
|
|
1831
|
+
patternPos += 1;
|
|
1832
|
+
}
|
|
1833
|
+
wordPos += 1;
|
|
1834
|
+
}
|
|
1835
|
+
return patternPos === patternLen; // pattern must be exhausted
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1839
|
+
const traceHighlights = (table, arrows, patternLength, wordLength) => {
|
|
1840
|
+
let row = patternLength;
|
|
1841
|
+
let column = wordLength;
|
|
1842
|
+
const matches = [];
|
|
1843
|
+
while (row >= 1 && column >= 1) {
|
|
1844
|
+
const arrow = arrows[row][column];
|
|
1845
|
+
if (arrow === Left) {
|
|
1846
|
+
column--;
|
|
1847
|
+
} else if (arrow === Diagonal) {
|
|
1848
|
+
row--;
|
|
1849
|
+
column--;
|
|
1850
|
+
const start = column + 1;
|
|
1851
|
+
while (row >= 1 && column >= 1) {
|
|
1852
|
+
const arrow = arrows[row][column];
|
|
1853
|
+
if (arrow === Left) {
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1856
|
+
if (arrow === Diagonal) {
|
|
1857
|
+
row--;
|
|
1858
|
+
column--;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
const end = column;
|
|
1862
|
+
matches.unshift(end, start);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
matches.unshift(table[patternLength][wordLength - 1]);
|
|
1866
|
+
return matches;
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1870
|
+
const gridSize = 128;
|
|
1871
|
+
const table = createTable(gridSize);
|
|
1872
|
+
const arrows = createTable(gridSize);
|
|
1873
|
+
const fuzzySearch = (pattern, word) => {
|
|
1874
|
+
const patternLength = Math.min(pattern.length, gridSize - 1);
|
|
1875
|
+
const wordLength = Math.min(word.length, gridSize - 1);
|
|
1876
|
+
const patternLower = pattern.toLowerCase();
|
|
1877
|
+
const wordLower = word.toLowerCase();
|
|
1878
|
+
if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
|
|
1879
|
+
return EmptyMatches;
|
|
1833
1880
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1881
|
+
let strongMatch = false;
|
|
1882
|
+
for (let row = 1; row < patternLength + 1; row++) {
|
|
1883
|
+
const rowChar = pattern[row - 1];
|
|
1884
|
+
const rowCharLow = patternLower[row - 1];
|
|
1885
|
+
for (let column = 1; column < wordLength + 1; column++) {
|
|
1886
|
+
const columnChar = word[column - 1];
|
|
1887
|
+
const columnCharLow = wordLower[column - 1];
|
|
1888
|
+
const columnCharBefore = word[column - 2] || '';
|
|
1889
|
+
const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
|
|
1890
|
+
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
1891
|
+
if (row === 1 && score > 5) {
|
|
1892
|
+
strongMatch = true;
|
|
1893
|
+
}
|
|
1894
|
+
let diagonalScore = score + table[row - 1][column - 1];
|
|
1895
|
+
if (isDiagonalMatch && score !== -1) {
|
|
1896
|
+
diagonalScore += 2;
|
|
1897
|
+
}
|
|
1898
|
+
const leftScore = table[row][column - 1];
|
|
1899
|
+
if (leftScore > diagonalScore) {
|
|
1900
|
+
table[row][column] = leftScore;
|
|
1901
|
+
arrows[row][column] = Left;
|
|
1902
|
+
} else {
|
|
1903
|
+
table[row][column] = diagonalScore;
|
|
1904
|
+
arrows[row][column] = Diagonal;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1836
1907
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
return
|
|
1842
|
-
...state,
|
|
1843
|
-
deltaY,
|
|
1844
|
-
minLineY,
|
|
1845
|
-
maxLineY
|
|
1846
|
-
};
|
|
1847
|
-
};
|
|
1848
|
-
const handleWheel = (state, deltaMode, deltaY) => {
|
|
1849
|
-
object(state);
|
|
1850
|
-
number(deltaMode);
|
|
1851
|
-
number(deltaY);
|
|
1852
|
-
return setDeltaY(state, state.deltaY + deltaY);
|
|
1908
|
+
if (!strongMatch) {
|
|
1909
|
+
return EmptyMatches;
|
|
1910
|
+
}
|
|
1911
|
+
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
1912
|
+
return highlights;
|
|
1853
1913
|
};
|
|
1854
1914
|
|
|
1855
|
-
const
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
icons: [],
|
|
1859
|
-
state: Default$1,
|
|
1860
|
-
picks: [],
|
|
1861
|
-
recentPicks: [],
|
|
1862
|
-
recentPickIds: new Map(),
|
|
1863
|
-
// TODO use object.create(null) instead
|
|
1864
|
-
versionId: 0,
|
|
1865
|
-
provider: QuickPickEntriesEverything,
|
|
1866
|
-
// TODO make this dynamic again
|
|
1867
|
-
warned: [],
|
|
1868
|
-
maxVisibleItems: 10,
|
|
1869
|
-
uri,
|
|
1870
|
-
cursorOffset: 0,
|
|
1871
|
-
height: 300,
|
|
1872
|
-
top: 50,
|
|
1873
|
-
width: 600,
|
|
1874
|
-
...create$1({
|
|
1875
|
-
itemHeight: listItemHeight,
|
|
1876
|
-
headerHeight: 30,
|
|
1877
|
-
minimumSliderSize: minimumSliderSize
|
|
1878
|
-
}),
|
|
1879
|
-
inputSource: User,
|
|
1880
|
-
args,
|
|
1881
|
-
focused: false,
|
|
1882
|
-
platform,
|
|
1883
|
-
value: '',
|
|
1884
|
-
fileIconCache: Object.create(null)
|
|
1885
|
-
};
|
|
1886
|
-
set(uid, state, state);
|
|
1915
|
+
const filterQuickPickItem = (pattern, word) => {
|
|
1916
|
+
const matches = fuzzySearch(pattern, word);
|
|
1917
|
+
return matches;
|
|
1887
1918
|
};
|
|
1888
1919
|
|
|
1889
|
-
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
const RenderFocusedIndex = 8;
|
|
1894
|
-
const Height = 9;
|
|
1920
|
+
// TODO this should be in FileSystem module
|
|
1921
|
+
const pathBaseName = path => {
|
|
1922
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
1923
|
+
};
|
|
1895
1924
|
|
|
1896
|
-
|
|
1897
|
-
const
|
|
1898
|
-
|
|
1925
|
+
// TODO this should be in FileSystem module
|
|
1926
|
+
const pathDirName = path => {
|
|
1927
|
+
const pathSeparator = '/';
|
|
1928
|
+
const index = path.lastIndexOf(pathSeparator);
|
|
1929
|
+
if (index === -1) {
|
|
1930
|
+
return '';
|
|
1931
|
+
}
|
|
1932
|
+
return path.slice(0, index);
|
|
1899
1933
|
};
|
|
1900
1934
|
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1935
|
+
const filterQuickPickItems = (items, value, provider) => {
|
|
1936
|
+
if (!value) {
|
|
1937
|
+
return items.map(convertToPick);
|
|
1938
|
+
}
|
|
1939
|
+
const results = [];
|
|
1940
|
+
for (const item of items) {
|
|
1941
|
+
let filterValue = '';
|
|
1942
|
+
if (provider) {
|
|
1943
|
+
// @ts-ignore
|
|
1944
|
+
filterValue = provider.getPickLabel(item);
|
|
1945
|
+
} else {
|
|
1946
|
+
filterValue = pathBaseName(item);
|
|
1947
|
+
}
|
|
1948
|
+
const matches = filterQuickPickItem(value, filterValue);
|
|
1949
|
+
if (matches.length > 0) {
|
|
1950
|
+
results.push({
|
|
1951
|
+
pick: item,
|
|
1952
|
+
matches
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
return results;
|
|
1904
1957
|
};
|
|
1905
1958
|
|
|
1906
|
-
|
|
1907
|
-
const
|
|
1908
|
-
|
|
1959
|
+
// TODO when user types letters -> no need to query provider again -> just filter existing results
|
|
1960
|
+
const setValue = async (state, newValue) => {
|
|
1961
|
+
const {
|
|
1962
|
+
value,
|
|
1963
|
+
provider,
|
|
1964
|
+
minLineY,
|
|
1965
|
+
maxLineY,
|
|
1966
|
+
fileIconCache
|
|
1967
|
+
} = state;
|
|
1968
|
+
if (value === newValue) {
|
|
1969
|
+
return state;
|
|
1970
|
+
}
|
|
1971
|
+
const newPicks = await provider.getPicks(newValue);
|
|
1972
|
+
const filterValue = provider.getFilterValue(newValue);
|
|
1973
|
+
const items = filterQuickPickItems(newPicks, filterValue, provider);
|
|
1974
|
+
const focusedIndex = items.length === 0 ? -1 : 0;
|
|
1975
|
+
const sliced = newPicks.slice(minLineY, maxLineY);
|
|
1976
|
+
const {
|
|
1977
|
+
newFileIconCache,
|
|
1978
|
+
icons
|
|
1979
|
+
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
1980
|
+
return {
|
|
1981
|
+
...state,
|
|
1982
|
+
picks: newPicks,
|
|
1983
|
+
items,
|
|
1984
|
+
focusedIndex,
|
|
1985
|
+
inputSource: Script,
|
|
1986
|
+
value: newValue,
|
|
1987
|
+
icons,
|
|
1988
|
+
fileIconCache: newFileIconCache
|
|
1989
|
+
};
|
|
1909
1990
|
};
|
|
1910
1991
|
|
|
1911
|
-
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1992
|
+
// TODO when user types letters -> no need to query provider again -> just filter existing results
|
|
1993
|
+
const handleInput = async (state, newValue, cursorOffset, inputSource = Script) => {
|
|
1994
|
+
if (state.value === newValue) {
|
|
1995
|
+
return state;
|
|
1996
|
+
}
|
|
1997
|
+
const newState = await setValue(state, newValue);
|
|
1998
|
+
return {
|
|
1999
|
+
...newState,
|
|
2000
|
+
cursorOffset,
|
|
2001
|
+
inputSource
|
|
2002
|
+
};
|
|
1914
2003
|
};
|
|
1915
2004
|
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1918
|
-
|
|
2005
|
+
const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd) => {
|
|
2006
|
+
string(inputType);
|
|
2007
|
+
number(selectionStart);
|
|
2008
|
+
number(selectionEnd);
|
|
2009
|
+
const {
|
|
2010
|
+
value
|
|
2011
|
+
} = state;
|
|
2012
|
+
const {
|
|
2013
|
+
newValue,
|
|
2014
|
+
cursorOffset
|
|
2015
|
+
} = getNewValue(value, inputType, data, selectionStart, selectionEnd);
|
|
2016
|
+
return handleInput(state, newValue, cursorOffset, User);
|
|
1919
2017
|
};
|
|
1920
2018
|
|
|
1921
|
-
const
|
|
1922
|
-
|
|
2019
|
+
const handleBlur = async state => {
|
|
2020
|
+
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
2021
|
+
// await CloseWidget.closeWidget(state.uid)
|
|
2022
|
+
return state;
|
|
2023
|
+
};
|
|
1923
2024
|
|
|
1924
|
-
const
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2025
|
+
const getPick = (items, index) => {
|
|
2026
|
+
array(items);
|
|
2027
|
+
number(index);
|
|
2028
|
+
// if (index < state.recentPicks.length) {
|
|
2029
|
+
// return state.recentPicks[index]
|
|
2030
|
+
// }
|
|
2031
|
+
// index -= state.recentPicks.length
|
|
2032
|
+
if (index < items.length) {
|
|
2033
|
+
return items[index].pick;
|
|
1931
2034
|
}
|
|
1932
|
-
|
|
2035
|
+
console.warn('no pick matching index', index);
|
|
1933
2036
|
};
|
|
1934
2037
|
|
|
1935
|
-
const
|
|
2038
|
+
const selectIndex = async (state, index, button = /* left */0) => {
|
|
1936
2039
|
const {
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
2040
|
+
minLineY,
|
|
2041
|
+
provider,
|
|
2042
|
+
items
|
|
2043
|
+
} = state;
|
|
2044
|
+
const actualIndex = index + minLineY;
|
|
2045
|
+
const pick = getPick(items, actualIndex);
|
|
2046
|
+
// @ts-ignore
|
|
2047
|
+
const selectPickResult = await provider.selectPick(pick, actualIndex, button);
|
|
2048
|
+
object(selectPickResult);
|
|
2049
|
+
string(selectPickResult.command);
|
|
2050
|
+
const {
|
|
2051
|
+
command
|
|
2052
|
+
} = selectPickResult;
|
|
2053
|
+
switch (command) {
|
|
2054
|
+
case Hide:
|
|
2055
|
+
await closeWidget(state.uid);
|
|
2056
|
+
return state;
|
|
2057
|
+
default:
|
|
2058
|
+
return state;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
// TODO recent picks should be per provider
|
|
2062
|
+
// if (!state.recentPickIds.has(pick.id)) {
|
|
2063
|
+
// state.recentPicks.unshift(pick)
|
|
2064
|
+
// state.recentPickIds.add(pick.id)
|
|
2065
|
+
// }
|
|
2066
|
+
// if (state.recentPicks.length > RECENT_PICKS_MAX_SIZE) {
|
|
2067
|
+
// const last = state.recentPicks.pop()
|
|
2068
|
+
// state.recentPickIds.delete(last.id)
|
|
2069
|
+
// }
|
|
1941
2070
|
};
|
|
1942
2071
|
|
|
1943
|
-
const
|
|
1944
|
-
|
|
2072
|
+
const handleClickAt = (state, x, y) => {
|
|
2073
|
+
const {
|
|
2074
|
+
top,
|
|
2075
|
+
headerHeight,
|
|
2076
|
+
itemHeight
|
|
2077
|
+
} = state;
|
|
2078
|
+
const relativeY = y - top - headerHeight;
|
|
2079
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
2080
|
+
return selectIndex(state, index);
|
|
1945
2081
|
};
|
|
1946
2082
|
|
|
1947
|
-
const
|
|
1948
|
-
|
|
2083
|
+
const setFocus = async focusKey => {
|
|
2084
|
+
await invoke$1('Focus.setFocus', focusKey);
|
|
1949
2085
|
};
|
|
1950
2086
|
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
type: File$2,
|
|
1957
|
-
name: dirent.name,
|
|
1958
|
-
path: dirent.path
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
return missingRequests;
|
|
2087
|
+
const handleFocus = async state => {
|
|
2088
|
+
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
2089
|
+
await setFocus(FocusQuickPickInput);
|
|
2090
|
+
// await CloseWidget.closeWidget(state.uid)
|
|
2091
|
+
return state;
|
|
1963
2092
|
};
|
|
1964
2093
|
|
|
1965
|
-
const
|
|
1966
|
-
|
|
1967
|
-
|
|
2094
|
+
const getDefaultValue = uri => {
|
|
2095
|
+
switch (uri) {
|
|
2096
|
+
case 'quickPick://everything':
|
|
2097
|
+
return '>';
|
|
2098
|
+
default:
|
|
1968
2099
|
return '';
|
|
1969
|
-
}
|
|
1970
|
-
return request.type === File$2 ? invoke$1('IconTheme.getFileIcon', {
|
|
1971
|
-
name: request.name
|
|
1972
|
-
}) : invoke$1('IconTheme.getFolderIcon', {
|
|
1973
|
-
name: request.name
|
|
1974
|
-
});
|
|
1975
|
-
});
|
|
1976
|
-
return Promise.all(promises);
|
|
1977
|
-
};
|
|
1978
|
-
|
|
1979
|
-
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
1980
|
-
if (missingRequests.length === 0) {
|
|
1981
|
-
return iconCache;
|
|
1982
|
-
}
|
|
1983
|
-
const newFileIconCache = {
|
|
1984
|
-
...iconCache
|
|
1985
|
-
};
|
|
1986
|
-
for (let i = 0; i < missingRequests.length; i++) {
|
|
1987
|
-
const request = missingRequests[i];
|
|
1988
|
-
const icon = newIcons[i];
|
|
1989
|
-
newFileIconCache[request.path] = icon;
|
|
1990
2100
|
}
|
|
1991
|
-
return newFileIconCache;
|
|
1992
|
-
};
|
|
1993
|
-
|
|
1994
|
-
const emptyDirent = {
|
|
1995
|
-
name: '',
|
|
1996
|
-
path: '',
|
|
1997
|
-
type: 0
|
|
1998
|
-
};
|
|
1999
|
-
const getQuickPickFileIcons = async (provider, items, fileIconCache) => {
|
|
2000
|
-
const dirents = items.map(item => {
|
|
2001
|
-
const dirent = provider.getPickFileIcon?.(item) || emptyDirent;
|
|
2002
|
-
return dirent;
|
|
2003
|
-
});
|
|
2004
|
-
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
2005
|
-
const newIcons = await requestFileIcons(missingRequests);
|
|
2006
|
-
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
2007
|
-
const paths = dirents.map(file => file.path);
|
|
2008
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
2009
|
-
return {
|
|
2010
|
-
icons,
|
|
2011
|
-
newFileIconCache
|
|
2012
|
-
};
|
|
2013
2101
|
};
|
|
2014
2102
|
|
|
2015
|
-
const
|
|
2103
|
+
const loadContent = async state => {
|
|
2016
2104
|
const {
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
items,
|
|
2020
|
-
minLineY,
|
|
2021
|
-
maxLineY,
|
|
2105
|
+
uri,
|
|
2106
|
+
args,
|
|
2022
2107
|
fileIconCache
|
|
2023
2108
|
} = state;
|
|
2024
|
-
|
|
2109
|
+
const value = getDefaultValue(uri);
|
|
2110
|
+
const provider = get$1(uri);
|
|
2025
2111
|
// @ts-ignore
|
|
2026
|
-
if (provider.
|
|
2112
|
+
if (provider.setArgs) {
|
|
2027
2113
|
// @ts-ignore
|
|
2028
|
-
|
|
2029
|
-
}
|
|
2030
|
-
if (index < minLineY + 1) {
|
|
2031
|
-
const minLineY = index;
|
|
2032
|
-
const maxLineY = Math.min(index + maxVisibleItems, items.length - 1);
|
|
2033
|
-
const sliced = items.slice(minLineY, maxLineY);
|
|
2034
|
-
const {
|
|
2035
|
-
newFileIconCache,
|
|
2036
|
-
icons
|
|
2037
|
-
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
2038
|
-
|
|
2039
|
-
// TODO need to scroll up
|
|
2040
|
-
return {
|
|
2041
|
-
...state,
|
|
2042
|
-
minLineY,
|
|
2043
|
-
maxLineY,
|
|
2044
|
-
focusedIndex: index,
|
|
2045
|
-
icons,
|
|
2046
|
-
fileIconCache: newFileIconCache
|
|
2047
|
-
};
|
|
2048
|
-
}
|
|
2049
|
-
if (index >= maxLineY - 1) {
|
|
2050
|
-
// TODO need to scroll down
|
|
2051
|
-
const maxLineY = index + 1;
|
|
2052
|
-
const minLineY = Math.max(maxLineY - maxVisibleItems, 0);
|
|
2053
|
-
const sliced = items.slice(minLineY, maxLineY);
|
|
2054
|
-
const {
|
|
2055
|
-
newFileIconCache,
|
|
2056
|
-
icons
|
|
2057
|
-
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
2058
|
-
return {
|
|
2059
|
-
...state,
|
|
2060
|
-
minLineY,
|
|
2061
|
-
maxLineY,
|
|
2062
|
-
focusedIndex: index,
|
|
2063
|
-
fileIconCache: newFileIconCache,
|
|
2064
|
-
icons
|
|
2065
|
-
};
|
|
2114
|
+
provider.setArgs(args);
|
|
2066
2115
|
}
|
|
2067
|
-
const
|
|
2116
|
+
const newPicks = await provider.getPicks(value);
|
|
2117
|
+
array(newPicks);
|
|
2118
|
+
const filterValue = provider.getFilterValue(value);
|
|
2119
|
+
const items = filterQuickPickItems(newPicks, filterValue, provider);
|
|
2120
|
+
const minLineY = 0;
|
|
2121
|
+
const maxLineY = Math.min(minLineY + state.maxVisibleItems, newPicks.length);
|
|
2122
|
+
const sliced = newPicks.slice(minLineY, maxLineY);
|
|
2068
2123
|
const {
|
|
2069
2124
|
newFileIconCache,
|
|
2070
2125
|
icons
|
|
2071
2126
|
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
2072
2127
|
return {
|
|
2073
2128
|
...state,
|
|
2074
|
-
|
|
2129
|
+
picks: newPicks,
|
|
2130
|
+
items,
|
|
2131
|
+
focusedIndex: 0,
|
|
2132
|
+
state: Finished,
|
|
2133
|
+
minLineY,
|
|
2134
|
+
maxLineY,
|
|
2135
|
+
value,
|
|
2136
|
+
cursorOffset: value.length,
|
|
2137
|
+
provider,
|
|
2138
|
+
inputSource: Script,
|
|
2139
|
+
focused: true,
|
|
2075
2140
|
fileIconCache: newFileIconCache,
|
|
2076
2141
|
icons
|
|
2077
2142
|
};
|
|
2078
2143
|
};
|
|
2079
2144
|
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2082
|
-
};
|
|
2083
|
-
const last = items => {
|
|
2084
|
-
return items.length - 1;
|
|
2085
|
-
};
|
|
2086
|
-
const next = (items, index) => {
|
|
2087
|
-
return (index + 1) % items.length;
|
|
2088
|
-
};
|
|
2089
|
-
const previous = (items, index) => {
|
|
2090
|
-
return index === 0 ? items.length - 1 : index - 1;
|
|
2091
|
-
};
|
|
2092
|
-
|
|
2093
|
-
const focusFirst = state => {
|
|
2094
|
-
return focusIndex(state, first());
|
|
2145
|
+
const state$9 = {
|
|
2146
|
+
menuEntries: []
|
|
2095
2147
|
};
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
const {
|
|
2099
|
-
items
|
|
2100
|
-
} = state;
|
|
2101
|
-
return focusIndex(state, last(items));
|
|
2148
|
+
const getAll = () => {
|
|
2149
|
+
return state$9.menuEntries;
|
|
2102
2150
|
};
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
const {
|
|
2106
|
-
items,
|
|
2107
|
-
focusedIndex
|
|
2108
|
-
} = state;
|
|
2109
|
-
const nextIndex = next(items, focusedIndex);
|
|
2110
|
-
return focusIndex(state, nextIndex);
|
|
2151
|
+
const add = menuEntries => {
|
|
2152
|
+
state$9.menuEntries = [...state$9.menuEntries, ...menuEntries];
|
|
2111
2153
|
};
|
|
2112
2154
|
|
|
2113
|
-
const
|
|
2114
|
-
const
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
const previousIndex = previous(items, focusedIndex);
|
|
2119
|
-
return focusIndex(state, previousIndex);
|
|
2155
|
+
const getVisible = (provider, items, minLineY, maxLineY, focusedIndex, icons) => {
|
|
2156
|
+
const setSize = items.length;
|
|
2157
|
+
const range = items.slice(minLineY, maxLineY);
|
|
2158
|
+
const visibleItems = provider.getVisibleItems(range, minLineY, maxLineY, focusedIndex, setSize, icons);
|
|
2159
|
+
return visibleItems;
|
|
2120
2160
|
};
|
|
2121
2161
|
|
|
2122
|
-
const
|
|
2123
|
-
|
|
2124
|
-
const
|
|
2125
|
-
|
|
2162
|
+
const createQuickPickViewModel = (oldState, newState) => {
|
|
2163
|
+
const visibleItems = getVisible(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.icons);
|
|
2164
|
+
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
2165
|
+
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
2166
|
+
const maxLineY = Math.min(newState.maxLineY, newState.items.length);
|
|
2167
|
+
const itemCount = maxLineY - newState.minLineY;
|
|
2168
|
+
const height = itemCount * newState.itemHeight;
|
|
2169
|
+
return {
|
|
2170
|
+
visibleItems,
|
|
2171
|
+
value: newState.value,
|
|
2172
|
+
cursorOffset: newState.cursorOffset,
|
|
2173
|
+
focused: newState.focused,
|
|
2174
|
+
height,
|
|
2175
|
+
oldFocusedIndex,
|
|
2176
|
+
newFocusedIndex,
|
|
2177
|
+
uid: newState.uid
|
|
2178
|
+
};
|
|
2126
2179
|
};
|
|
2127
|
-
|
|
2128
|
-
const
|
|
2129
|
-
const
|
|
2130
|
-
const
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2135
|
-
const FocusQuickPickInput = 20;
|
|
2136
|
-
|
|
2137
|
-
const getKeyBindings = () => {
|
|
2138
|
-
return [{
|
|
2139
|
-
key: Escape,
|
|
2140
|
-
command: 'Viewlet.closeWidget',
|
|
2141
|
-
args: ['QuickPick'],
|
|
2142
|
-
when: FocusQuickPickInput
|
|
2143
|
-
}, {
|
|
2144
|
-
key: UpArrow,
|
|
2145
|
-
command: 'QuickPick.focusPrevious',
|
|
2146
|
-
when: FocusQuickPickInput
|
|
2147
|
-
}, {
|
|
2148
|
-
key: DownArrow,
|
|
2149
|
-
command: 'QuickPick.focusNext',
|
|
2150
|
-
when: FocusQuickPickInput
|
|
2151
|
-
}, {
|
|
2152
|
-
key: PageUp,
|
|
2153
|
-
command: 'QuickPick.focusFirst',
|
|
2154
|
-
when: FocusQuickPickInput
|
|
2155
|
-
}, {
|
|
2156
|
-
key: PageDown,
|
|
2157
|
-
command: 'QuickPick.focusLast',
|
|
2158
|
-
when: FocusQuickPickInput
|
|
2159
|
-
}, {
|
|
2160
|
-
key: Enter,
|
|
2161
|
-
command: 'QuickPick.selectCurrentIndex',
|
|
2162
|
-
when: FocusQuickPickInput
|
|
2163
|
-
}];
|
|
2180
|
+
|
|
2181
|
+
const SetCursorOffset = 'setCursorOffset';
|
|
2182
|
+
const SetFocusedIndex = 'setFocusedIndex';
|
|
2183
|
+
const SetItemsHeight = 'setItemsHeight';
|
|
2184
|
+
const SetValue = 'setValue';
|
|
2185
|
+
|
|
2186
|
+
const renderCursorOffset = newState => {
|
|
2187
|
+
return ['Viewlet.send', newState.uid, /* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
|
|
2164
2188
|
};
|
|
2165
2189
|
|
|
2166
|
-
const
|
|
2167
|
-
const DeleteContentBackward = 'deleteContentBackward';
|
|
2168
|
-
const DeleteContentForward = 'deleteContentForward';
|
|
2169
|
-
const DeleteWordForward = 'deleteWordForward';
|
|
2170
|
-
const DeleteWordBackward = 'deleteWordBackward';
|
|
2171
|
-
const InsertLineBreak = 'insertLineBreak';
|
|
2172
|
-
const InsertCompositionText = 'insertCompositionText';
|
|
2173
|
-
const InsertFromPaste = 'insertFromPaste';
|
|
2190
|
+
const QuickPickInput = 'QuickPickInput';
|
|
2174
2191
|
|
|
2175
|
-
const
|
|
2176
|
-
|
|
2177
|
-
return RE_ALPHA_NUMERIC.test(character);
|
|
2192
|
+
const renderFocus = newState => {
|
|
2193
|
+
return ['Viewlet.focusElementByName', QuickPickInput];
|
|
2178
2194
|
};
|
|
2179
2195
|
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
const newValue = value + data;
|
|
2183
|
-
return {
|
|
2184
|
-
newValue,
|
|
2185
|
-
cursorOffset: newValue.length
|
|
2186
|
-
};
|
|
2187
|
-
}
|
|
2188
|
-
const before = value.slice(0, selectionStart);
|
|
2189
|
-
const after = value.slice(selectionEnd);
|
|
2190
|
-
const newValue = before + data + after;
|
|
2191
|
-
return {
|
|
2192
|
-
newValue,
|
|
2193
|
-
cursorOffset: selectionStart + data.length
|
|
2194
|
-
};
|
|
2196
|
+
const renderFocusedIndex = newState => {
|
|
2197
|
+
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */newState.oldFocusedIndex, /* newFocusedIndex */newState.newFocusedIndex];
|
|
2195
2198
|
};
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
if (
|
|
2199
|
-
|
|
2200
|
-
const newValue = before + after;
|
|
2201
|
-
return {
|
|
2202
|
-
newValue,
|
|
2203
|
-
cursorOffset: before.length
|
|
2204
|
-
};
|
|
2199
|
+
|
|
2200
|
+
const renderHeight = newState => {
|
|
2201
|
+
if (newState.height === 0) {
|
|
2202
|
+
return ['Viewlet.send', newState.uid, /* method */SetItemsHeight, /* height */20];
|
|
2205
2203
|
}
|
|
2206
|
-
|
|
2207
|
-
const newValue = before + after;
|
|
2208
|
-
return {
|
|
2209
|
-
newValue,
|
|
2210
|
-
cursorOffset: selectionStart
|
|
2211
|
-
};
|
|
2204
|
+
return ['Viewlet.send', newState.uid, /* method */SetItemsHeight, /* height */newState.height];
|
|
2212
2205
|
};
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2206
|
+
|
|
2207
|
+
const ComboBox = 'combobox';
|
|
2208
|
+
const ListBox = 'listbox';
|
|
2209
|
+
const None$1 = 'none';
|
|
2210
|
+
const Option = 'option';
|
|
2211
|
+
|
|
2212
|
+
const FileIcon = 'FileIcon';
|
|
2213
|
+
const InputBox = 'InputBox';
|
|
2214
|
+
const Label = 'Label';
|
|
2215
|
+
const QuickPick$1 = 'QuickPick';
|
|
2216
|
+
const QuickPickHeader = 'QuickPickHeader';
|
|
2217
|
+
const QuickPickHighlight = 'QuickPickHighlight';
|
|
2218
|
+
const QuickPickItem = 'QuickPickItem';
|
|
2219
|
+
const QuickPickItemActive$1 = 'QuickPickItemActive';
|
|
2220
|
+
const QuickPickItemDescription = 'QuickPickItemDescription';
|
|
2221
|
+
const QuickPickItemLabel = 'QuickPickItemLabel';
|
|
2222
|
+
const QuickPickItems$1 = 'QuickPickItems';
|
|
2223
|
+
const Viewlet = 'Viewlet';
|
|
2224
|
+
|
|
2225
|
+
const HandleBeforeInput = 'handleBeforeInput';
|
|
2226
|
+
const HandleBlur = 'handleBlur';
|
|
2227
|
+
const HandleFocus = 'handleFocus';
|
|
2228
|
+
const HandleInput = 'handleInput';
|
|
2229
|
+
const HandlePointerDown = 'handlePointerDown';
|
|
2230
|
+
const HandleWheel = 'handleWheel';
|
|
2231
|
+
|
|
2232
|
+
const QuickPick = 'QuickPick';
|
|
2233
|
+
const QuickPickItems = 'QuickPickItems';
|
|
2234
|
+
const QuickPickItemActive = 'QuickPickItemActive';
|
|
2235
|
+
|
|
2236
|
+
const Div = 4;
|
|
2237
|
+
const Input = 6;
|
|
2238
|
+
const Span = 8;
|
|
2239
|
+
const Img = 17;
|
|
2240
|
+
|
|
2241
|
+
const getQuickPickInputVirtualDom = () => {
|
|
2242
|
+
const ariaLabel = typeNameofCommandToRun();
|
|
2229
2243
|
return {
|
|
2230
|
-
|
|
2231
|
-
|
|
2244
|
+
type: Input,
|
|
2245
|
+
className: InputBox,
|
|
2246
|
+
spellcheck: false,
|
|
2247
|
+
autocapitalize: 'off',
|
|
2248
|
+
inputType: 'text',
|
|
2249
|
+
childCount: 0,
|
|
2250
|
+
role: ComboBox,
|
|
2251
|
+
name: QuickPickInput,
|
|
2252
|
+
onBeforeInput: HandleBeforeInput,
|
|
2253
|
+
onBlur: HandleBlur,
|
|
2254
|
+
onInput: HandleInput,
|
|
2255
|
+
onFocus: HandleFocus,
|
|
2256
|
+
ariaLabel: ariaLabel,
|
|
2257
|
+
ariaAutoComplete: 'list',
|
|
2258
|
+
ariaExpanded: true,
|
|
2259
|
+
autocomplete: 'off'
|
|
2232
2260
|
};
|
|
2233
2261
|
};
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2262
|
+
|
|
2263
|
+
const getQuickPickHeaderVirtualDom = () => {
|
|
2264
|
+
return [{
|
|
2265
|
+
type: Div,
|
|
2266
|
+
className: QuickPickHeader,
|
|
2267
|
+
childCount: 1
|
|
2268
|
+
}, getQuickPickInputVirtualDom()];
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
const mergeClassNames = (...classNames) => {
|
|
2272
|
+
return classNames.filter(Boolean).join(' ');
|
|
2273
|
+
};
|
|
2274
|
+
const Text = 12;
|
|
2275
|
+
const text = data => {
|
|
2246
2276
|
return {
|
|
2247
|
-
|
|
2248
|
-
|
|
2277
|
+
type: Text,
|
|
2278
|
+
text: data,
|
|
2279
|
+
childCount: 0
|
|
2249
2280
|
};
|
|
2250
2281
|
};
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2282
|
+
|
|
2283
|
+
const quickPickHighlight = {
|
|
2284
|
+
type: Span,
|
|
2285
|
+
className: QuickPickHighlight,
|
|
2286
|
+
childCount: 1
|
|
2287
|
+
};
|
|
2288
|
+
const addHighlights = (dom, highlights, label) => {
|
|
2289
|
+
const labelDom = {
|
|
2290
|
+
type: Div,
|
|
2291
|
+
className: QuickPickItemLabel,
|
|
2292
|
+
childCount: 0
|
|
2293
|
+
};
|
|
2294
|
+
dom.push(labelDom);
|
|
2295
|
+
let position = 0;
|
|
2296
|
+
for (let i = 0; i < highlights.length; i += 2) {
|
|
2297
|
+
const highlightStart = highlights[i];
|
|
2298
|
+
const highlightEnd = highlights[i + 1];
|
|
2299
|
+
if (position < highlightStart) {
|
|
2300
|
+
const beforeText = label.slice(position, highlightStart);
|
|
2301
|
+
labelDom.childCount++;
|
|
2302
|
+
dom.push(text(beforeText));
|
|
2257
2303
|
}
|
|
2258
|
-
const
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2304
|
+
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
2305
|
+
labelDom.childCount++;
|
|
2306
|
+
dom.push(quickPickHighlight, text(highlightText));
|
|
2307
|
+
position = highlightEnd;
|
|
2308
|
+
}
|
|
2309
|
+
if (position < label.length) {
|
|
2310
|
+
const afterText = label.slice(position);
|
|
2311
|
+
labelDom.childCount++;
|
|
2312
|
+
dom.push(text(afterText));
|
|
2264
2313
|
}
|
|
2265
|
-
const after = value.slice(selectionEnd);
|
|
2266
|
-
const newValue = before + after;
|
|
2267
|
-
return {
|
|
2268
|
-
newValue,
|
|
2269
|
-
cursorOffset: selectionStart
|
|
2270
|
-
};
|
|
2271
|
-
};
|
|
2272
|
-
const getNewValueInsertCompositionText = (value, selectionStart, selectionEnd, data) => {
|
|
2273
|
-
return getNewValueInsertText(value, selectionStart, selectionEnd, data);
|
|
2274
2314
|
};
|
|
2275
|
-
|
|
2315
|
+
|
|
2316
|
+
const getFileIconVirtualDom = icon => {
|
|
2276
2317
|
return {
|
|
2277
|
-
|
|
2278
|
-
|
|
2318
|
+
type: Img,
|
|
2319
|
+
className: FileIcon,
|
|
2320
|
+
src: icon,
|
|
2321
|
+
role: None$1,
|
|
2322
|
+
childCount: 0
|
|
2279
2323
|
};
|
|
2280
2324
|
};
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2325
|
+
|
|
2326
|
+
const getQuickPickItemVirtualDom = visibleItem => {
|
|
2327
|
+
const {
|
|
2328
|
+
posInSet,
|
|
2329
|
+
label,
|
|
2330
|
+
setSize,
|
|
2331
|
+
isActive,
|
|
2332
|
+
description,
|
|
2333
|
+
icon,
|
|
2334
|
+
matches,
|
|
2335
|
+
fileIcon
|
|
2336
|
+
} = visibleItem;
|
|
2337
|
+
const highlights = matches.slice(1);
|
|
2338
|
+
const dom = [];
|
|
2339
|
+
dom.push({
|
|
2340
|
+
type: Div,
|
|
2341
|
+
className: QuickPickItem,
|
|
2342
|
+
role: Option,
|
|
2343
|
+
ariaPosInSet: posInSet,
|
|
2344
|
+
ariaSetSize: setSize,
|
|
2345
|
+
childCount: 1
|
|
2346
|
+
});
|
|
2347
|
+
const parent = dom[0];
|
|
2348
|
+
if (isActive) {
|
|
2349
|
+
// @ts-ignore
|
|
2350
|
+
parent.id = 'QuickPickItemActive';
|
|
2351
|
+
parent.className += ' ' + QuickPickItemActive$1;
|
|
2300
2352
|
}
|
|
2353
|
+
if (fileIcon) {
|
|
2354
|
+
parent.childCount++;
|
|
2355
|
+
dom.push(getFileIconVirtualDom(fileIcon));
|
|
2356
|
+
} else if (icon) {
|
|
2357
|
+
parent.childCount++;
|
|
2358
|
+
dom.push({
|
|
2359
|
+
type: Div,
|
|
2360
|
+
className: mergeClassNames(`QuickPickMaskIcon`, 'MaskIcon', `MaskIcon${icon}`),
|
|
2361
|
+
childCount: 0
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
addHighlights(dom, highlights, label);
|
|
2365
|
+
if (description) {
|
|
2366
|
+
parent.childCount++;
|
|
2367
|
+
dom.push({
|
|
2368
|
+
type: Div,
|
|
2369
|
+
className: QuickPickItemDescription,
|
|
2370
|
+
childCount: 1
|
|
2371
|
+
}, text(description));
|
|
2372
|
+
}
|
|
2373
|
+
return dom;
|
|
2301
2374
|
};
|
|
2302
2375
|
|
|
2303
|
-
const
|
|
2304
|
-
const
|
|
2305
|
-
return
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
};
|
|
2376
|
+
const getQuickPickNoResultsVirtualDom = () => {
|
|
2377
|
+
const noResults$1 = noResults();
|
|
2378
|
+
return [{
|
|
2379
|
+
type: Div,
|
|
2380
|
+
className: 'QuickPickItem QuickPickItemActive QuickPickStatus',
|
|
2381
|
+
childCount: 1
|
|
2382
|
+
}, {
|
|
2383
|
+
type: Div,
|
|
2384
|
+
className: Label,
|
|
2385
|
+
childCount: 1
|
|
2386
|
+
}, text(noResults$1)];
|
|
2315
2387
|
};
|
|
2316
2388
|
|
|
2317
|
-
const
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
2321
|
-
|
|
2322
|
-
const createTable = size => {
|
|
2323
|
-
const table = [];
|
|
2324
|
-
for (let i = 0; i < size; i++) {
|
|
2325
|
-
const row = new Uint8Array(size);
|
|
2326
|
-
table.push(row);
|
|
2389
|
+
const getQuickPickItemsVirtualDom = visibleItems => {
|
|
2390
|
+
if (visibleItems.length === 0) {
|
|
2391
|
+
return getQuickPickNoResultsVirtualDom();
|
|
2327
2392
|
}
|
|
2328
|
-
|
|
2393
|
+
const dom = visibleItems.flatMap(getQuickPickItemVirtualDom);
|
|
2394
|
+
return dom;
|
|
2329
2395
|
};
|
|
2330
|
-
|
|
2331
|
-
const
|
|
2332
|
-
const
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2396
|
+
|
|
2397
|
+
const getQuickPickVirtualDom = visibleItems => {
|
|
2398
|
+
const quickOpen$1 = quickOpen();
|
|
2399
|
+
return [{
|
|
2400
|
+
type: Div,
|
|
2401
|
+
className: mergeClassNames(Viewlet, QuickPick$1),
|
|
2402
|
+
childCount: 2,
|
|
2403
|
+
id: QuickPick,
|
|
2404
|
+
ariaLabel: quickOpen$1
|
|
2405
|
+
}, ...getQuickPickHeaderVirtualDom(), {
|
|
2406
|
+
type: Div,
|
|
2407
|
+
className: QuickPickItems$1,
|
|
2408
|
+
id: QuickPickItems,
|
|
2409
|
+
role: ListBox,
|
|
2410
|
+
ariaActivedescendant: QuickPickItemActive,
|
|
2411
|
+
onWheel: HandleWheel,
|
|
2412
|
+
childCount: visibleItems.length
|
|
2413
|
+
}, ...getQuickPickItemsVirtualDom(visibleItems)];
|
|
2339
2414
|
};
|
|
2340
|
-
|
|
2341
|
-
|
|
2415
|
+
|
|
2416
|
+
const renderItems = newState => {
|
|
2417
|
+
const dom = getQuickPickVirtualDom(newState.visibleItems);
|
|
2418
|
+
return ['Viewlet.setDom2', dom];
|
|
2342
2419
|
};
|
|
2343
2420
|
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
switch (columnCharBefore) {
|
|
2347
|
-
case Dash:
|
|
2348
|
-
case Underline:
|
|
2349
|
-
case EmptyString:
|
|
2350
|
-
case T:
|
|
2351
|
-
case Space:
|
|
2352
|
-
case Dot:
|
|
2353
|
-
return true;
|
|
2354
|
-
}
|
|
2355
|
-
if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
|
|
2356
|
-
return true;
|
|
2357
|
-
}
|
|
2358
|
-
return false;
|
|
2421
|
+
const renderValue = newState => {
|
|
2422
|
+
return ['Viewlet.send', newState.uid, /* method */SetValue, /* value */newState.value];
|
|
2359
2423
|
};
|
|
2360
2424
|
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
return
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
return 8;
|
|
2425
|
+
const getRenderer = diffType => {
|
|
2426
|
+
switch (diffType) {
|
|
2427
|
+
case RenderValue:
|
|
2428
|
+
return renderValue;
|
|
2429
|
+
case RenderCursorOffset:
|
|
2430
|
+
return renderCursorOffset;
|
|
2431
|
+
case RenderItems:
|
|
2432
|
+
return renderItems;
|
|
2433
|
+
case RenderFocusedIndex:
|
|
2434
|
+
return renderFocusedIndex;
|
|
2435
|
+
case Height:
|
|
2436
|
+
return renderHeight;
|
|
2437
|
+
case RenderFocus:
|
|
2438
|
+
return renderFocus;
|
|
2439
|
+
default:
|
|
2440
|
+
throw new Error('unknown renderer');
|
|
2378
2441
|
}
|
|
2379
|
-
return 5;
|
|
2380
2442
|
};
|
|
2381
2443
|
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
const
|
|
2385
|
-
|
|
2386
|
-
if (
|
|
2387
|
-
|
|
2444
|
+
const applyRender = (oldState, newState, diffResult) => {
|
|
2445
|
+
const commands = [];
|
|
2446
|
+
const viewModel = createQuickPickViewModel(oldState, newState);
|
|
2447
|
+
for (const item of diffResult) {
|
|
2448
|
+
if (item === Height) {
|
|
2449
|
+
continue;
|
|
2388
2450
|
}
|
|
2389
|
-
|
|
2451
|
+
if (item === RenderFocusedIndex) {
|
|
2452
|
+
continue;
|
|
2453
|
+
}
|
|
2454
|
+
const fn = getRenderer(item);
|
|
2455
|
+
commands.push(fn(viewModel));
|
|
2390
2456
|
}
|
|
2391
|
-
return
|
|
2457
|
+
return commands;
|
|
2392
2458
|
};
|
|
2393
2459
|
|
|
2394
|
-
|
|
2395
|
-
const
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
if (arrow === Left) {
|
|
2402
|
-
column--;
|
|
2403
|
-
} else if (arrow === Diagonal) {
|
|
2404
|
-
row--;
|
|
2405
|
-
column--;
|
|
2406
|
-
const start = column + 1;
|
|
2407
|
-
while (row >= 1 && column >= 1) {
|
|
2408
|
-
const arrow = arrows[row][column];
|
|
2409
|
-
if (arrow === Left) {
|
|
2410
|
-
break;
|
|
2411
|
-
}
|
|
2412
|
-
if (arrow === Diagonal) {
|
|
2413
|
-
row--;
|
|
2414
|
-
column--;
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
const end = column;
|
|
2418
|
-
matches.unshift(end, start);
|
|
2419
|
-
}
|
|
2460
|
+
const render2 = (uid, diffResult) => {
|
|
2461
|
+
const {
|
|
2462
|
+
oldState,
|
|
2463
|
+
newState
|
|
2464
|
+
} = get(uid);
|
|
2465
|
+
if (oldState === newState) {
|
|
2466
|
+
return [];
|
|
2420
2467
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2468
|
+
set(uid, newState, newState);
|
|
2469
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
2470
|
+
return commands;
|
|
2423
2471
|
};
|
|
2424
2472
|
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
2447
|
-
if (row === 1 && score > 5) {
|
|
2448
|
-
strongMatch = true;
|
|
2449
|
-
}
|
|
2450
|
-
let diagonalScore = score + table[row - 1][column - 1];
|
|
2451
|
-
if (isDiagonalMatch && score !== -1) {
|
|
2452
|
-
diagonalScore += 2;
|
|
2453
|
-
}
|
|
2454
|
-
const leftScore = table[row][column - 1];
|
|
2455
|
-
if (leftScore > diagonalScore) {
|
|
2456
|
-
table[row][column] = leftScore;
|
|
2457
|
-
arrows[row][column] = Left;
|
|
2458
|
-
} else {
|
|
2459
|
-
table[row][column] = diagonalScore;
|
|
2460
|
-
arrows[row][column] = Diagonal;
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
if (!strongMatch) {
|
|
2465
|
-
return EmptyMatches;
|
|
2466
|
-
}
|
|
2467
|
-
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
2468
|
-
return highlights;
|
|
2473
|
+
const renderEventListeners = () => {
|
|
2474
|
+
return [{
|
|
2475
|
+
name: HandlePointerDown,
|
|
2476
|
+
params: ['handlePointerDown', 'event.clientX', 'event.clientY'],
|
|
2477
|
+
preventDefault: true
|
|
2478
|
+
}, {
|
|
2479
|
+
name: HandleWheel,
|
|
2480
|
+
params: ['handleWheel', 'event.deltaMode', 'event.deltaY']
|
|
2481
|
+
}, {
|
|
2482
|
+
name: HandleBlur,
|
|
2483
|
+
params: ['handleBlur']
|
|
2484
|
+
}, {
|
|
2485
|
+
name: HandleBeforeInput,
|
|
2486
|
+
params: ['handleBeforeInput']
|
|
2487
|
+
}, {
|
|
2488
|
+
name: HandleInput,
|
|
2489
|
+
params: ['handleInput', 'event.target.value']
|
|
2490
|
+
}, {
|
|
2491
|
+
name: HandleFocus,
|
|
2492
|
+
params: ['handleFocus']
|
|
2493
|
+
}];
|
|
2469
2494
|
};
|
|
2470
2495
|
|
|
2471
|
-
const
|
|
2472
|
-
|
|
2473
|
-
return matches;
|
|
2496
|
+
const selectCurrentIndex = state => {
|
|
2497
|
+
return selectIndex(state, state.focusedIndex);
|
|
2474
2498
|
};
|
|
2475
2499
|
|
|
2476
|
-
const
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
const results = [];
|
|
2481
|
-
for (const item of items) {
|
|
2482
|
-
let filterValue = '';
|
|
2483
|
-
if (provider) {
|
|
2484
|
-
filterValue = provider.getPickLabel(item);
|
|
2485
|
-
} else {
|
|
2486
|
-
filterValue = pathBaseName(item);
|
|
2487
|
-
}
|
|
2488
|
-
const matches = filterQuickPickItem(value, filterValue);
|
|
2489
|
-
if (matches.length > 0) {
|
|
2490
|
-
results.push({
|
|
2491
|
-
pick: item,
|
|
2492
|
-
matches
|
|
2493
|
-
});
|
|
2500
|
+
const findLabelIndex = (items, label) => {
|
|
2501
|
+
for (let i = 0; i < items.length; i++) {
|
|
2502
|
+
if (items[i].pick.label === label) {
|
|
2503
|
+
return i;
|
|
2494
2504
|
}
|
|
2495
2505
|
}
|
|
2496
|
-
return
|
|
2506
|
+
return -1;
|
|
2497
2507
|
};
|
|
2498
2508
|
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
const
|
|
2502
|
-
|
|
2503
|
-
provider,
|
|
2504
|
-
minLineY,
|
|
2505
|
-
maxLineY,
|
|
2506
|
-
fileIconCache
|
|
2507
|
-
} = state;
|
|
2508
|
-
if (value === newValue) {
|
|
2509
|
+
const selectItem = async (state, label) => {
|
|
2510
|
+
string(label);
|
|
2511
|
+
const index = findLabelIndex(state.items, label);
|
|
2512
|
+
if (index === -1) {
|
|
2509
2513
|
return state;
|
|
2510
2514
|
}
|
|
2511
|
-
|
|
2512
|
-
const filterValue = provider.getFilterValue(newValue);
|
|
2513
|
-
const items = filterQuickPickItems(newPicks, filterValue, provider);
|
|
2514
|
-
const focusedIndex = items.length === 0 ? -1 : 0;
|
|
2515
|
-
const sliced = newPicks.slice(minLineY, maxLineY);
|
|
2516
|
-
const {
|
|
2517
|
-
newFileIconCache,
|
|
2518
|
-
icons
|
|
2519
|
-
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
2520
|
-
return {
|
|
2521
|
-
...state,
|
|
2522
|
-
picks: newPicks,
|
|
2523
|
-
items,
|
|
2524
|
-
focusedIndex,
|
|
2525
|
-
inputSource: Script,
|
|
2526
|
-
value: newValue,
|
|
2527
|
-
icons,
|
|
2528
|
-
fileIconCache: newFileIconCache
|
|
2529
|
-
};
|
|
2515
|
+
return selectIndex(state, index);
|
|
2530
2516
|
};
|
|
2531
2517
|
|
|
2532
|
-
|
|
2533
|
-
const
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2518
|
+
const wrapCommand = fn => {
|
|
2519
|
+
const wrapped = async (uid, ...args) => {
|
|
2520
|
+
const {
|
|
2521
|
+
newState
|
|
2522
|
+
} = get(uid);
|
|
2523
|
+
const newerState = await fn(newState, ...args);
|
|
2524
|
+
if (newState === newerState) {
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
const latest = get(uid);
|
|
2528
|
+
set(uid, latest.oldState, newerState);
|
|
2542
2529
|
};
|
|
2530
|
+
return wrapped;
|
|
2543
2531
|
};
|
|
2544
2532
|
|
|
2545
|
-
const
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2533
|
+
const commandMap = {
|
|
2534
|
+
'QuickPick.addMenuEntries': add,
|
|
2535
|
+
'QuickPick.close': close,
|
|
2536
|
+
'QuickPick.create2': create,
|
|
2537
|
+
'QuickPick.diff2': diff2,
|
|
2538
|
+
'QuickPick.dispose': dispose,
|
|
2539
|
+
'QuickPick.focusFirst': wrapCommand(focusFirst),
|
|
2540
|
+
'QuickPick.focusIndex': wrapCommand(focusIndex),
|
|
2541
|
+
'QuickPick.focusLast': wrapCommand(focusLast),
|
|
2542
|
+
'QuickPick.focusNext': wrapCommand(focusNext),
|
|
2543
|
+
'QuickPick.focusPrevious': wrapCommand(focusPrevious),
|
|
2544
|
+
'QuickPick.getCommandIds': getCommandIds,
|
|
2545
|
+
'QuickPick.getKeyBindings': getKeyBindings,
|
|
2546
|
+
'QuickPick.handleBeforeInput': wrapCommand(handleBeforeInput),
|
|
2547
|
+
'QuickPick.handleBlur': wrapCommand(handleBlur),
|
|
2548
|
+
'QuickPick.handleClickAt': wrapCommand(handleClickAt),
|
|
2549
|
+
'QuickPick.handleFocus': wrapCommand(handleFocus),
|
|
2550
|
+
'QuickPick.handleInput': wrapCommand(handleInput),
|
|
2551
|
+
'QuickPick.handleWheel': wrapCommand(handleWheel),
|
|
2552
|
+
'QuickPick.loadContent': wrapCommand(loadContent),
|
|
2553
|
+
'QuickPick.render2': render2,
|
|
2554
|
+
'QuickPick.renderEventListeners': renderEventListeners,
|
|
2555
|
+
'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
|
|
2556
|
+
'QuickPick.selectIndex': wrapCommand(selectIndex),
|
|
2557
|
+
'QuickPick.selectItem': wrapCommand(selectItem),
|
|
2558
|
+
'QuickPick.setDeltaY': wrapCommand(setDeltaY),
|
|
2559
|
+
'QuickPick.setValue': wrapCommand(setValue),
|
|
2560
|
+
// deprecated
|
|
2561
|
+
'QuickPick.loadEntries2': get$1
|
|
2557
2562
|
};
|
|
2558
2563
|
|
|
2559
|
-
const
|
|
2560
|
-
|
|
2561
|
-
// await CloseWidget.closeWidget(state.uid)
|
|
2562
|
-
return state;
|
|
2564
|
+
const getColorThemeNames = async () => {
|
|
2565
|
+
return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
|
|
2563
2566
|
};
|
|
2564
2567
|
|
|
2565
|
-
const
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2568
|
+
const setColorTheme = id => {
|
|
2569
|
+
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
2570
|
+
};
|
|
2571
|
+
const getPlaceholder$7 = () => {
|
|
2572
|
+
return selectColorTheme();
|
|
2573
|
+
};
|
|
2574
|
+
const getLabel$4 = () => {
|
|
2575
|
+
return selectColorTheme();
|
|
2576
|
+
};
|
|
2577
|
+
const getPicks$7 = async searchValue => {
|
|
2578
|
+
const colorThemeNames = await getColorThemeNames();
|
|
2579
|
+
return colorThemeNames;
|
|
2580
|
+
};
|
|
2581
|
+
const getVisibleItems$7 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
2582
|
+
const visibleItems = picks.map((pick, index) => ({
|
|
2583
|
+
description: getPickDescription$7(),
|
|
2584
|
+
fileIcon: '',
|
|
2585
|
+
icon: getPickIcon$7(),
|
|
2586
|
+
isActive: index + minLineY === focusedIndex,
|
|
2587
|
+
label: getPickLabel$7(pick),
|
|
2588
|
+
matches: [],
|
|
2589
|
+
posInSet: index + minLineY + 1,
|
|
2590
|
+
setSize
|
|
2591
|
+
}));
|
|
2592
|
+
return visibleItems;
|
|
2593
|
+
};
|
|
2594
|
+
const selectPick$7 = async pick => {
|
|
2595
|
+
await setColorTheme(/* colorThemeId */pick);
|
|
2596
|
+
return {
|
|
2597
|
+
command: Hide
|
|
2598
|
+
};
|
|
2599
|
+
};
|
|
2600
|
+
const focusPick = async pick => {
|
|
2601
|
+
await setColorTheme(/* colorThemeId */pick);
|
|
2602
|
+
};
|
|
2603
|
+
const getFilterValue$7 = value => {
|
|
2604
|
+
return value;
|
|
2605
|
+
};
|
|
2606
|
+
const getNoResults$7 = () => {
|
|
2607
|
+
return {
|
|
2608
|
+
label: noMatchingColorThemesFound()
|
|
2609
|
+
};
|
|
2610
|
+
};
|
|
2611
|
+
const getPickFilterValue$7 = pick => {
|
|
2612
|
+
return pick;
|
|
2613
|
+
};
|
|
2614
|
+
const getPickLabel$7 = pick => {
|
|
2615
|
+
return pick;
|
|
2616
|
+
};
|
|
2617
|
+
const getPickIcon$7 = pick => {
|
|
2618
|
+
return '';
|
|
2619
|
+
};
|
|
2620
|
+
const state$8 = {};
|
|
2621
|
+
const getPickDescription$7 = value => {
|
|
2622
|
+
return '';
|
|
2623
|
+
};
|
|
2624
|
+
const isPrepared$7 = () => {
|
|
2625
|
+
return false;
|
|
2626
|
+
};
|
|
2627
|
+
const name$7 = '';
|
|
2628
|
+
const getHelpEntries$2 = () => {
|
|
2629
|
+
return [];
|
|
2576
2630
|
};
|
|
2577
2631
|
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
default:
|
|
2598
|
-
return state;
|
|
2599
|
-
}
|
|
2600
|
-
|
|
2601
|
-
// TODO recent picks should be per provider
|
|
2602
|
-
// if (!state.recentPickIds.has(pick.id)) {
|
|
2603
|
-
// state.recentPicks.unshift(pick)
|
|
2604
|
-
// state.recentPickIds.add(pick.id)
|
|
2605
|
-
// }
|
|
2606
|
-
// if (state.recentPicks.length > RECENT_PICKS_MAX_SIZE) {
|
|
2607
|
-
// const last = state.recentPicks.pop()
|
|
2608
|
-
// state.recentPickIds.delete(last.id)
|
|
2609
|
-
// }
|
|
2632
|
+
const QuickPickEntriesColorTheme = {
|
|
2633
|
+
__proto__: null,
|
|
2634
|
+
focusPick,
|
|
2635
|
+
getFilterValue: getFilterValue$7,
|
|
2636
|
+
getHelpEntries: getHelpEntries$2,
|
|
2637
|
+
getLabel: getLabel$4,
|
|
2638
|
+
getNoResults: getNoResults$7,
|
|
2639
|
+
getPickDescription: getPickDescription$7,
|
|
2640
|
+
getPickFilterValue: getPickFilterValue$7,
|
|
2641
|
+
getPickIcon: getPickIcon$7,
|
|
2642
|
+
getPickLabel: getPickLabel$7,
|
|
2643
|
+
getPicks: getPicks$7,
|
|
2644
|
+
getPlaceholder: getPlaceholder$7,
|
|
2645
|
+
getVisibleItems: getVisibleItems$7,
|
|
2646
|
+
isPrepared: isPrepared$7,
|
|
2647
|
+
name: name$7,
|
|
2648
|
+
selectPick: selectPick$7,
|
|
2649
|
+
setColorTheme,
|
|
2650
|
+
state: state$8
|
|
2610
2651
|
};
|
|
2611
2652
|
|
|
2612
|
-
const
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
const
|
|
2619
|
-
const
|
|
2620
|
-
|
|
2653
|
+
const handleError = async (error, notify = true, prefix = '') => {
|
|
2654
|
+
console.error(error);
|
|
2655
|
+
};
|
|
2656
|
+
const showErrorDialog = async error => {
|
|
2657
|
+
const code = error.code;
|
|
2658
|
+
const message = error.message;
|
|
2659
|
+
const stack = error.stack;
|
|
2660
|
+
const name = error.name;
|
|
2661
|
+
const errorInfo = {
|
|
2662
|
+
code,
|
|
2663
|
+
message,
|
|
2664
|
+
stack,
|
|
2665
|
+
name
|
|
2666
|
+
};
|
|
2667
|
+
await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
|
|
2668
|
+
};
|
|
2669
|
+
const warn = (...args) => {
|
|
2670
|
+
console.warn(...args);
|
|
2621
2671
|
};
|
|
2622
2672
|
|
|
2623
|
-
const
|
|
2624
|
-
|
|
2673
|
+
const name$6 = 'command';
|
|
2674
|
+
const state$7 = {};
|
|
2675
|
+
const isPrepared$6 = () => {
|
|
2676
|
+
return false;
|
|
2677
|
+
};
|
|
2678
|
+
const getPickDescription$6 = () => {
|
|
2679
|
+
return '';
|
|
2680
|
+
};
|
|
2681
|
+
const getPlaceholder$6 = () => {
|
|
2682
|
+
return typeNameofCommandToRun();
|
|
2683
|
+
};
|
|
2684
|
+
const getLabel$3 = () => {
|
|
2685
|
+
return '';
|
|
2686
|
+
};
|
|
2687
|
+
const getNoResults$6 = () => {
|
|
2688
|
+
return {
|
|
2689
|
+
label: noMatchingResults()
|
|
2690
|
+
};
|
|
2625
2691
|
};
|
|
2626
2692
|
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2693
|
+
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
2694
|
+
const getBuiltinPicks = async () => {
|
|
2695
|
+
const builtinPicks = getAll();
|
|
2696
|
+
return builtinPicks;
|
|
2697
|
+
};
|
|
2698
|
+
const prefixIdWithExt = item => {
|
|
2699
|
+
if (!item.label) {
|
|
2700
|
+
warn('[QuickPick] item has missing label', item);
|
|
2701
|
+
}
|
|
2702
|
+
if (!item.id) {
|
|
2703
|
+
warn('[QuickPick] item has missing id', item);
|
|
2630
2704
|
}
|
|
2631
|
-
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
2632
|
-
await setFocus(FocusQuickPickInput);
|
|
2633
|
-
// await CloseWidget.closeWidget(state.uid)
|
|
2634
2705
|
return {
|
|
2635
|
-
...
|
|
2636
|
-
|
|
2706
|
+
...item,
|
|
2707
|
+
id: `ext.${item.id}`,
|
|
2708
|
+
label: item.label || item.id
|
|
2637
2709
|
};
|
|
2638
2710
|
};
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2711
|
+
const getExtensionPicks = async () => {
|
|
2712
|
+
try {
|
|
2713
|
+
// TODO don't call this every time
|
|
2714
|
+
const extensionPicks = await invoke$1('ExtensionHost.getCommands');
|
|
2715
|
+
if (!extensionPicks) {
|
|
2716
|
+
return [];
|
|
2717
|
+
}
|
|
2718
|
+
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
2719
|
+
return mappedPicks;
|
|
2720
|
+
} catch (error) {
|
|
2721
|
+
console.error(`Failed to get extension picks: ${error}`);
|
|
2722
|
+
return [];
|
|
2646
2723
|
}
|
|
2647
2724
|
};
|
|
2648
2725
|
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2726
|
+
// TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
|
|
2727
|
+
|
|
2728
|
+
const getPicks$6 = async () => {
|
|
2729
|
+
const builtinPicks = await getBuiltinPicks();
|
|
2730
|
+
const extensionPicks = await getExtensionPicks();
|
|
2731
|
+
const allPicks = [...builtinPicks, ...extensionPicks];
|
|
2732
|
+
return allPicks;
|
|
2652
2733
|
};
|
|
2653
|
-
const
|
|
2654
|
-
const
|
|
2655
|
-
|
|
2656
|
-
|
|
2734
|
+
const getVisibleItems$6 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
2735
|
+
const visibleItems = picks.map((pick, index) => ({
|
|
2736
|
+
description: pick.description || '',
|
|
2737
|
+
fileIcon: '',
|
|
2738
|
+
icon: getPickIcon$6(),
|
|
2739
|
+
isActive: index + minLineY === focusedIndex,
|
|
2740
|
+
label: getPickLabel$6(pick),
|
|
2741
|
+
matches: [],
|
|
2742
|
+
posInSet: index + minLineY + 1,
|
|
2743
|
+
setSize
|
|
2744
|
+
}));
|
|
2745
|
+
return visibleItems;
|
|
2746
|
+
};
|
|
2747
|
+
const shouldHide = item => {
|
|
2748
|
+
if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
|
|
2749
|
+
return false;
|
|
2657
2750
|
}
|
|
2658
|
-
return
|
|
2751
|
+
return true;
|
|
2659
2752
|
};
|
|
2660
|
-
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
const provider = get(uri);
|
|
2669
|
-
// @ts-ignore
|
|
2670
|
-
if (provider.setArgs) {
|
|
2671
|
-
// @ts-ignore
|
|
2672
|
-
provider.setArgs(args);
|
|
2753
|
+
const selectPickBuiltin = async item => {
|
|
2754
|
+
const args = item.args || [];
|
|
2755
|
+
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
2756
|
+
await invoke$1(item.id, ...args);
|
|
2757
|
+
if (shouldHide(item)) {
|
|
2758
|
+
return {
|
|
2759
|
+
command: Hide
|
|
2760
|
+
};
|
|
2673
2761
|
}
|
|
2674
|
-
const newPicks = await provider.getPicks(value);
|
|
2675
|
-
array(newPicks);
|
|
2676
|
-
const filterValue = provider.getFilterValue(value);
|
|
2677
|
-
const items = filterQuickPickItems(newPicks, filterValue, provider);
|
|
2678
|
-
const minLineY = 0;
|
|
2679
|
-
const maxLineY = Math.min(minLineY + state.maxVisibleItems, newPicks.length);
|
|
2680
|
-
const sliced = newPicks.slice(minLineY, maxLineY);
|
|
2681
|
-
const {
|
|
2682
|
-
newFileIconCache,
|
|
2683
|
-
icons
|
|
2684
|
-
} = await getQuickPickFileIcons(provider, sliced, fileIconCache);
|
|
2685
2762
|
return {
|
|
2686
|
-
|
|
2687
|
-
picks: newPicks,
|
|
2688
|
-
items,
|
|
2689
|
-
focusedIndex: 0,
|
|
2690
|
-
state: Finished,
|
|
2691
|
-
minLineY,
|
|
2692
|
-
maxLineY,
|
|
2693
|
-
value,
|
|
2694
|
-
cursorOffset: value.length,
|
|
2695
|
-
provider,
|
|
2696
|
-
inputSource: Script,
|
|
2697
|
-
focused: true,
|
|
2698
|
-
fileIconCache: newFileIconCache,
|
|
2699
|
-
icons
|
|
2763
|
+
command: KeepOpen
|
|
2700
2764
|
};
|
|
2701
2765
|
};
|
|
2702
|
-
|
|
2703
|
-
const
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
const createQuickPickViewModel = (oldState, newState) => {
|
|
2711
|
-
const visibleItems = getVisible(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.icons);
|
|
2712
|
-
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
2713
|
-
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
2714
|
-
const maxLineY = Math.min(newState.maxLineY, newState.items.length);
|
|
2715
|
-
const itemCount = maxLineY - newState.minLineY;
|
|
2716
|
-
const height = itemCount * newState.itemHeight;
|
|
2766
|
+
const selectPickExtension = async item => {
|
|
2767
|
+
const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
|
|
2768
|
+
try {
|
|
2769
|
+
await invoke$1('ExtensionHost.executeCommand', id);
|
|
2770
|
+
} catch (error) {
|
|
2771
|
+
await handleError(error, false);
|
|
2772
|
+
await showErrorDialog(error);
|
|
2773
|
+
}
|
|
2717
2774
|
return {
|
|
2718
|
-
|
|
2719
|
-
value: newState.value,
|
|
2720
|
-
cursorOffset: newState.cursorOffset,
|
|
2721
|
-
focused: newState.focused,
|
|
2722
|
-
height,
|
|
2723
|
-
oldFocusedIndex,
|
|
2724
|
-
newFocusedIndex,
|
|
2725
|
-
uid: newState.uid
|
|
2775
|
+
command: Hide
|
|
2726
2776
|
};
|
|
2727
2777
|
};
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
const renderCursorOffset = newState => {
|
|
2735
|
-
return ['Viewlet.send', newState.uid, /* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
|
|
2778
|
+
const selectPick$6 = async item => {
|
|
2779
|
+
if (item.id.startsWith('ext.')) {
|
|
2780
|
+
return selectPickExtension(item);
|
|
2781
|
+
}
|
|
2782
|
+
return selectPickBuiltin(item);
|
|
2736
2783
|
};
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
const renderFocus = newState => {
|
|
2741
|
-
return ['Viewlet.focusElementByName', QuickPickInput];
|
|
2784
|
+
const getFilterValue$6 = value => {
|
|
2785
|
+
return value.trim();
|
|
2742
2786
|
};
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */newState.oldFocusedIndex, /* newFocusedIndex */newState.newFocusedIndex];
|
|
2787
|
+
const getPickFilterValue$6 = pick => {
|
|
2788
|
+
return pick.label;
|
|
2746
2789
|
};
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
return ['Viewlet.send', newState.uid, /* method */SetItemsHeight, /* height */newState.height];
|
|
2790
|
+
const getPickLabel$6 = pick => {
|
|
2791
|
+
return pick.label;
|
|
2792
|
+
};
|
|
2793
|
+
const getPickIcon$6 = () => {
|
|
2794
|
+
return '';
|
|
2753
2795
|
};
|
|
2754
2796
|
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
const HandleBeforeInput = 'handleBeforeInput';
|
|
2774
|
-
const HandleBlur = 'handleBlur';
|
|
2775
|
-
const HandleFocus = 'handleFocus';
|
|
2776
|
-
const HandleInput = 'handleInput';
|
|
2777
|
-
const HandlePointerDown = 'handlePointerDown';
|
|
2778
|
-
const HandleWheel = 'handleWheel';
|
|
2797
|
+
const QuickPickEntriesCommand = {
|
|
2798
|
+
__proto__: null,
|
|
2799
|
+
getFilterValue: getFilterValue$6,
|
|
2800
|
+
getLabel: getLabel$3,
|
|
2801
|
+
getNoResults: getNoResults$6,
|
|
2802
|
+
getPickDescription: getPickDescription$6,
|
|
2803
|
+
getPickFilterValue: getPickFilterValue$6,
|
|
2804
|
+
getPickIcon: getPickIcon$6,
|
|
2805
|
+
getPickLabel: getPickLabel$6,
|
|
2806
|
+
getPicks: getPicks$6,
|
|
2807
|
+
getPlaceholder: getPlaceholder$6,
|
|
2808
|
+
getVisibleItems: getVisibleItems$6,
|
|
2809
|
+
isPrepared: isPrepared$6,
|
|
2810
|
+
name: name$6,
|
|
2811
|
+
selectPick: selectPick$6,
|
|
2812
|
+
state: state$7
|
|
2813
|
+
};
|
|
2779
2814
|
|
|
2780
|
-
const
|
|
2781
|
-
const
|
|
2782
|
-
const
|
|
2815
|
+
const Tag$1 = 'Tag';
|
|
2816
|
+
const Cloud$1 = 'Cloud';
|
|
2817
|
+
const SourceControl$1 = 'SourceControl';
|
|
2818
|
+
const None = '';
|
|
2783
2819
|
|
|
2784
|
-
const
|
|
2785
|
-
const
|
|
2786
|
-
const
|
|
2787
|
-
const Img = 17;
|
|
2820
|
+
const SourceControl = 1;
|
|
2821
|
+
const Cloud = 2;
|
|
2822
|
+
const Tag = 3;
|
|
2788
2823
|
|
|
2789
|
-
const
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
type: Input,
|
|
2793
|
-
className: InputBox,
|
|
2794
|
-
spellcheck: false,
|
|
2795
|
-
autocapitalize: 'off',
|
|
2796
|
-
inputType: 'text',
|
|
2797
|
-
childCount: 0,
|
|
2798
|
-
role: ComboBox,
|
|
2799
|
-
name: QuickPickInput,
|
|
2800
|
-
onBeforeInput: HandleBeforeInput,
|
|
2801
|
-
onBlur: HandleBlur,
|
|
2802
|
-
onInput: HandleInput,
|
|
2803
|
-
onFocus: HandleFocus,
|
|
2804
|
-
ariaLabel: ariaLabel,
|
|
2805
|
-
ariaAutoComplete: 'list',
|
|
2806
|
-
ariaExpanded: true,
|
|
2807
|
-
autocomplete: 'off'
|
|
2808
|
-
};
|
|
2824
|
+
const name$5 = 'custom';
|
|
2825
|
+
const state$6 = {
|
|
2826
|
+
args: []
|
|
2809
2827
|
};
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2828
|
+
const setArgs = args => {
|
|
2829
|
+
state$6.args = args;
|
|
2830
|
+
};
|
|
2831
|
+
const getPlaceholder$5 = () => {
|
|
2832
|
+
return '';
|
|
2833
|
+
};
|
|
2834
|
+
const getLabel$2 = () => {
|
|
2835
|
+
return 'Custom';
|
|
2817
2836
|
};
|
|
2818
2837
|
|
|
2819
|
-
|
|
2820
|
-
|
|
2838
|
+
// TODO help entries should not be here
|
|
2839
|
+
const getHelpEntries$1 = () => {
|
|
2840
|
+
return [];
|
|
2821
2841
|
};
|
|
2822
|
-
const
|
|
2823
|
-
const text = data => {
|
|
2842
|
+
const getNoResults$5 = () => {
|
|
2824
2843
|
return {
|
|
2825
|
-
|
|
2826
|
-
text: data,
|
|
2827
|
-
childCount: 0
|
|
2844
|
+
label: noMatchingResults()
|
|
2828
2845
|
};
|
|
2829
2846
|
};
|
|
2830
|
-
|
|
2831
|
-
const
|
|
2832
|
-
|
|
2833
|
-
className: QuickPickHighlight,
|
|
2834
|
-
childCount: 1
|
|
2847
|
+
const getPicks$5 = async searchValue => {
|
|
2848
|
+
const items = state$6.args[1] || [];
|
|
2849
|
+
return items;
|
|
2835
2850
|
};
|
|
2836
|
-
const
|
|
2837
|
-
const
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2851
|
+
const selectPick$5 = async pick => {
|
|
2852
|
+
const {
|
|
2853
|
+
args
|
|
2854
|
+
} = state$6;
|
|
2855
|
+
const resolve = args[2];
|
|
2856
|
+
resolve(pick);
|
|
2857
|
+
return {
|
|
2858
|
+
command: Hide
|
|
2841
2859
|
};
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2860
|
+
};
|
|
2861
|
+
const getFilterValue$5 = value => {
|
|
2862
|
+
return value;
|
|
2863
|
+
};
|
|
2864
|
+
const getPickFilterValue$5 = pick => {
|
|
2865
|
+
return pick;
|
|
2866
|
+
};
|
|
2867
|
+
const getPickLabel$5 = pick => {
|
|
2868
|
+
return pick.label;
|
|
2869
|
+
};
|
|
2870
|
+
const getPickDescription$5 = pick => {
|
|
2871
|
+
return pick.description || '';
|
|
2872
|
+
};
|
|
2873
|
+
const convertIcon = icon => {
|
|
2874
|
+
switch (icon) {
|
|
2875
|
+
case SourceControl:
|
|
2876
|
+
return SourceControl$1;
|
|
2877
|
+
case Cloud:
|
|
2878
|
+
return Cloud$1;
|
|
2879
|
+
case Tag:
|
|
2880
|
+
return Tag$1;
|
|
2881
|
+
default:
|
|
2882
|
+
return None;
|
|
2861
2883
|
}
|
|
2862
2884
|
};
|
|
2885
|
+
const getPickIcon$5 = pick => {
|
|
2886
|
+
return convertIcon(pick.icon);
|
|
2887
|
+
};
|
|
2888
|
+
const isPrepared$5 = () => {
|
|
2889
|
+
return true;
|
|
2890
|
+
};
|
|
2891
|
+
const getVisibleItems$5 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
2892
|
+
const visibleItems = picks.slice(minLineY, maxLineY + 1).map((pick, index) => ({
|
|
2893
|
+
description: getPickDescription$5(pick),
|
|
2894
|
+
fileIcon: '',
|
|
2895
|
+
icon: getPickIcon$5(pick),
|
|
2896
|
+
isActive: index + minLineY === focusedIndex,
|
|
2897
|
+
label: getPickLabel$5(pick),
|
|
2898
|
+
matches: [],
|
|
2899
|
+
posInSet: index + minLineY + 1,
|
|
2900
|
+
setSize
|
|
2901
|
+
}));
|
|
2902
|
+
return visibleItems;
|
|
2903
|
+
};
|
|
2863
2904
|
|
|
2864
|
-
const
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2905
|
+
const QuickPickEntriesCustom = {
|
|
2906
|
+
__proto__: null,
|
|
2907
|
+
getFilterValue: getFilterValue$5,
|
|
2908
|
+
getHelpEntries: getHelpEntries$1,
|
|
2909
|
+
getLabel: getLabel$2,
|
|
2910
|
+
getNoResults: getNoResults$5,
|
|
2911
|
+
getPickDescription: getPickDescription$5,
|
|
2912
|
+
getPickFilterValue: getPickFilterValue$5,
|
|
2913
|
+
getPickIcon: getPickIcon$5,
|
|
2914
|
+
getPickLabel: getPickLabel$5,
|
|
2915
|
+
getPicks: getPicks$5,
|
|
2916
|
+
getPlaceholder: getPlaceholder$5,
|
|
2917
|
+
getVisibleItems: getVisibleItems$5,
|
|
2918
|
+
isPrepared: isPrepared$5,
|
|
2919
|
+
name: name$5,
|
|
2920
|
+
selectPick: selectPick$5,
|
|
2921
|
+
setArgs,
|
|
2922
|
+
state: state$6
|
|
2872
2923
|
};
|
|
2873
2924
|
|
|
2874
|
-
const
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
isActive,
|
|
2880
|
-
description,
|
|
2881
|
-
icon,
|
|
2882
|
-
matches,
|
|
2883
|
-
fileIcon
|
|
2884
|
-
} = visibleItem;
|
|
2885
|
-
const highlights = matches.slice(1);
|
|
2886
|
-
const dom = [];
|
|
2887
|
-
dom.push({
|
|
2888
|
-
type: Div,
|
|
2889
|
-
className: QuickPickItem,
|
|
2890
|
-
role: Option,
|
|
2891
|
-
ariaPosInSet: posInSet,
|
|
2892
|
-
ariaSetSize: setSize,
|
|
2893
|
-
childCount: 1
|
|
2894
|
-
});
|
|
2895
|
-
const parent = dom[0];
|
|
2896
|
-
if (isActive) {
|
|
2897
|
-
// @ts-ignore
|
|
2898
|
-
parent.id = 'QuickPickItemActive';
|
|
2899
|
-
parent.className += ' ' + QuickPickItemActive$1;
|
|
2900
|
-
}
|
|
2901
|
-
if (fileIcon) {
|
|
2902
|
-
parent.childCount++;
|
|
2903
|
-
dom.push(getFileIconVirtualDom(fileIcon));
|
|
2904
|
-
} else if (icon) {
|
|
2905
|
-
parent.childCount++;
|
|
2906
|
-
dom.push({
|
|
2907
|
-
type: Div,
|
|
2908
|
-
className: mergeClassNames(`QuickPickMaskIcon`, 'MaskIcon', `MaskIcon${icon}`),
|
|
2909
|
-
childCount: 0
|
|
2910
|
-
});
|
|
2911
|
-
}
|
|
2912
|
-
addHighlights(dom, highlights, label);
|
|
2913
|
-
if (description) {
|
|
2914
|
-
parent.childCount++;
|
|
2915
|
-
dom.push({
|
|
2916
|
-
type: Div,
|
|
2917
|
-
className: QuickPickItemDescription,
|
|
2918
|
-
childCount: 1
|
|
2919
|
-
}, text(description));
|
|
2925
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
2926
|
+
const getProtocol = uri => {
|
|
2927
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2928
|
+
if (protocolMatch) {
|
|
2929
|
+
return protocolMatch[1];
|
|
2920
2930
|
}
|
|
2921
|
-
return
|
|
2931
|
+
return '';
|
|
2922
2932
|
};
|
|
2923
2933
|
|
|
2924
|
-
const
|
|
2925
|
-
|
|
2926
|
-
return [{
|
|
2927
|
-
type: Div,
|
|
2928
|
-
className: 'QuickPickItem QuickPickItemActive QuickPickStatus',
|
|
2929
|
-
childCount: 1
|
|
2930
|
-
}, {
|
|
2931
|
-
type: Div,
|
|
2932
|
-
className: Label,
|
|
2933
|
-
childCount: 1
|
|
2934
|
-
}, text(noResults$1)];
|
|
2934
|
+
const getWorkspacePath = async () => {
|
|
2935
|
+
return invoke$1('Workspace.getPath');
|
|
2935
2936
|
};
|
|
2936
2937
|
|
|
2937
|
-
const
|
|
2938
|
-
|
|
2939
|
-
return getQuickPickNoResultsVirtualDom();
|
|
2940
|
-
}
|
|
2941
|
-
const dom = visibleItems.flatMap(getQuickPickItemVirtualDom);
|
|
2942
|
-
return dom;
|
|
2938
|
+
const openUri = async uri => {
|
|
2939
|
+
await invoke$1(/* Main.openUri */'Main.openUri', /* uri */uri);
|
|
2943
2940
|
};
|
|
2944
2941
|
|
|
2945
|
-
const
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
type: Div,
|
|
2949
|
-
className: mergeClassNames(Viewlet, QuickPick$1),
|
|
2950
|
-
childCount: 2,
|
|
2951
|
-
id: QuickPick,
|
|
2952
|
-
ariaLabel: quickOpen$1
|
|
2953
|
-
}, ...getQuickPickHeaderVirtualDom(), {
|
|
2954
|
-
type: Div,
|
|
2955
|
-
className: QuickPickItems$1,
|
|
2956
|
-
id: QuickPickItems,
|
|
2957
|
-
role: ListBox,
|
|
2958
|
-
ariaActivedescendant: QuickPickItemActive,
|
|
2959
|
-
onWheel: HandleWheel,
|
|
2960
|
-
childCount: visibleItems.length
|
|
2961
|
-
}, ...getQuickPickItemsVirtualDom(visibleItems)];
|
|
2942
|
+
const state$5 = Object.create(null);
|
|
2943
|
+
const register = modules => {
|
|
2944
|
+
Object.assign(state$5, modules);
|
|
2962
2945
|
};
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
const dom = getQuickPickVirtualDom(newState.visibleItems);
|
|
2966
|
-
return ['Viewlet.setDom2', dom];
|
|
2946
|
+
const getModule = protocol => {
|
|
2947
|
+
return state$5[protocol];
|
|
2967
2948
|
};
|
|
2968
2949
|
|
|
2969
|
-
const
|
|
2970
|
-
|
|
2950
|
+
const searchFile$5 = async (path, value, prepare, assetDir) => {
|
|
2951
|
+
const protocol = getProtocol(path);
|
|
2952
|
+
// TODO call different providers depending on protocol
|
|
2953
|
+
const fn = getModule(protocol);
|
|
2954
|
+
const result = await fn(path, value, prepare, assetDir);
|
|
2955
|
+
return result;
|
|
2971
2956
|
};
|
|
2972
2957
|
|
|
2973
|
-
const
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2958
|
+
const state$4 = {};
|
|
2959
|
+
const searchFile$4 = async (path, value) => {
|
|
2960
|
+
const prepare = true;
|
|
2961
|
+
// @ts-ignore
|
|
2962
|
+
const files = await searchFile$5(/* path */path, /* searchTerm */value, prepare);
|
|
2963
|
+
return files;
|
|
2964
|
+
};
|
|
2965
|
+
const name$4 = 'file';
|
|
2966
|
+
const getPlaceholder$4 = () => {
|
|
2967
|
+
return '';
|
|
2968
|
+
};
|
|
2969
|
+
const getLabel$1 = () => {
|
|
2970
|
+
return files();
|
|
2971
|
+
};
|
|
2972
|
+
const getNoResults$4 = () => {
|
|
2973
|
+
return {
|
|
2974
|
+
label: noMatchingResults()
|
|
2975
|
+
};
|
|
2976
|
+
};
|
|
2977
|
+
const getPicks$4 = async searchValue => {
|
|
2978
|
+
// TODO cache workspace path
|
|
2979
|
+
const workspace = await getWorkspacePath();
|
|
2980
|
+
if (!workspace) {
|
|
2981
|
+
return [];
|
|
2989
2982
|
}
|
|
2983
|
+
const files = await searchFile$4(workspace, searchValue);
|
|
2984
|
+
return files;
|
|
2990
2985
|
};
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
const viewModel = createQuickPickViewModel(oldState, newState);
|
|
2995
|
-
for (const item of diffResult) {
|
|
2996
|
-
if (item === Height) {
|
|
2997
|
-
continue;
|
|
2998
|
-
}
|
|
2999
|
-
if (item === RenderFocusedIndex) {
|
|
3000
|
-
continue;
|
|
3001
|
-
}
|
|
3002
|
-
const fn = getRenderer(item);
|
|
3003
|
-
commands.push(fn(viewModel));
|
|
2986
|
+
const selectPick$4 = async pick => {
|
|
2987
|
+
if (typeof pick === 'object') {
|
|
2988
|
+
pick = pick.pick;
|
|
3004
2989
|
}
|
|
3005
|
-
|
|
2990
|
+
const workspace = await getWorkspacePath();
|
|
2991
|
+
const absolutePath = `${workspace}/${pick}`;
|
|
2992
|
+
await openUri(absolutePath);
|
|
2993
|
+
return {
|
|
2994
|
+
command: Hide
|
|
2995
|
+
};
|
|
3006
2996
|
};
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
const {
|
|
3010
|
-
oldState,
|
|
3011
|
-
newState
|
|
3012
|
-
} = get$1(uid);
|
|
3013
|
-
set(uid, newState, newState);
|
|
3014
|
-
const commands = applyRender(oldState, newState, diffResult);
|
|
3015
|
-
return commands;
|
|
2997
|
+
const getFilterValue$4 = value => {
|
|
2998
|
+
return value;
|
|
3016
2999
|
};
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
preventDefault: true
|
|
3023
|
-
}, {
|
|
3024
|
-
name: HandleWheel,
|
|
3025
|
-
params: ['handleWheel', 'event.deltaMode', 'event.deltaY']
|
|
3026
|
-
}, {
|
|
3027
|
-
name: HandleBlur,
|
|
3028
|
-
params: ['handleBlur']
|
|
3029
|
-
}, {
|
|
3030
|
-
name: HandleBeforeInput,
|
|
3031
|
-
params: ['handleBeforeInput']
|
|
3032
|
-
}, {
|
|
3033
|
-
name: HandleInput,
|
|
3034
|
-
params: ['handleInput', 'event.target.value']
|
|
3035
|
-
}, {
|
|
3036
|
-
name: HandleFocus,
|
|
3037
|
-
params: ['handleFocus']
|
|
3038
|
-
}];
|
|
3000
|
+
const getPickFilterValue$4 = pick => {
|
|
3001
|
+
if (typeof pick === 'object') {
|
|
3002
|
+
pick = pick.pick;
|
|
3003
|
+
}
|
|
3004
|
+
return pick;
|
|
3039
3005
|
};
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3006
|
+
const getPickLabel$4 = pick => {
|
|
3007
|
+
if (typeof pick === 'object') {
|
|
3008
|
+
pick = pick.pick;
|
|
3009
|
+
}
|
|
3010
|
+
const baseName = pathBaseName(pick);
|
|
3011
|
+
return baseName;
|
|
3043
3012
|
};
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
if (items[i].pick.label === label) {
|
|
3048
|
-
return i;
|
|
3049
|
-
}
|
|
3013
|
+
const getPickDescription$4 = pick => {
|
|
3014
|
+
if (typeof pick === 'object') {
|
|
3015
|
+
pick = pick.pick;
|
|
3050
3016
|
}
|
|
3051
|
-
|
|
3017
|
+
const dirName = pathDirName(pick);
|
|
3018
|
+
return dirName;
|
|
3052
3019
|
};
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
if (
|
|
3058
|
-
|
|
3020
|
+
const getPickIcon$4 = () => {
|
|
3021
|
+
return '';
|
|
3022
|
+
};
|
|
3023
|
+
const getPickFileIcon$1 = pick => {
|
|
3024
|
+
if (typeof pick === 'object') {
|
|
3025
|
+
pick = pick.pick;
|
|
3059
3026
|
}
|
|
3060
|
-
|
|
3027
|
+
if (typeof pick === 'object') {
|
|
3028
|
+
pick = pick.pick;
|
|
3029
|
+
}
|
|
3030
|
+
const baseName = pathBaseName(pick);
|
|
3031
|
+
return {
|
|
3032
|
+
type: File$1,
|
|
3033
|
+
name: baseName,
|
|
3034
|
+
path: pick
|
|
3035
|
+
};
|
|
3061
3036
|
};
|
|
3062
|
-
|
|
3063
|
-
const
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
const
|
|
3073
|
-
const
|
|
3074
|
-
|
|
3075
|
-
|
|
3037
|
+
const isPrepared$4 = () => {
|
|
3038
|
+
const workspace = '';
|
|
3039
|
+
// TODO protocol should always be defined. For files it should use file protocol
|
|
3040
|
+
const protocol = getProtocol(workspace);
|
|
3041
|
+
return !protocol;
|
|
3042
|
+
};
|
|
3043
|
+
const getVisibleItems$4 = (files, minLineY, maxLineY, focusedIndex, setSize, icons) => {
|
|
3044
|
+
const visibleItems = files.map((item, i) => {
|
|
3045
|
+
const pick = item.pick;
|
|
3046
|
+
const label = getPickLabel$4(pick);
|
|
3047
|
+
const description = getPickDescription$4(pick);
|
|
3048
|
+
const icon = getPickIcon$4();
|
|
3049
|
+
const fileIcon = icons[i];
|
|
3050
|
+
return {
|
|
3051
|
+
label,
|
|
3052
|
+
description,
|
|
3053
|
+
icon,
|
|
3054
|
+
fileIcon,
|
|
3055
|
+
posInSet: minLineY + i + 1,
|
|
3056
|
+
setSize,
|
|
3057
|
+
isActive: i === focusedIndex,
|
|
3058
|
+
matches: item.matches
|
|
3076
3059
|
};
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
return wrapped;
|
|
3060
|
+
});
|
|
3061
|
+
return visibleItems;
|
|
3080
3062
|
};
|
|
3081
3063
|
|
|
3082
|
-
const
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
'QuickPick.handleInput': wrapCommand(handleInput),
|
|
3100
|
-
'QuickPick.handleWheel': wrapCommand(handleWheel),
|
|
3101
|
-
'QuickPick.loadContent': wrapCommand(loadContent),
|
|
3102
|
-
'QuickPick.loadEntries2': get,
|
|
3103
|
-
'QuickPick.render2': render2,
|
|
3104
|
-
'QuickPick.renderEventListeners': renderEventListeners,
|
|
3105
|
-
'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
|
|
3106
|
-
'QuickPick.selectIndex': wrapCommand(selectIndex),
|
|
3107
|
-
'QuickPick.selectItem': wrapCommand(selectItem),
|
|
3108
|
-
'QuickPick.setDeltaY': wrapCommand(setDeltaY),
|
|
3109
|
-
'QuickPick.setValue': wrapCommand(setValue)
|
|
3064
|
+
const QuickPickEntriesFile = {
|
|
3065
|
+
__proto__: null,
|
|
3066
|
+
getFilterValue: getFilterValue$4,
|
|
3067
|
+
getLabel: getLabel$1,
|
|
3068
|
+
getNoResults: getNoResults$4,
|
|
3069
|
+
getPickDescription: getPickDescription$4,
|
|
3070
|
+
getPickFileIcon: getPickFileIcon$1,
|
|
3071
|
+
getPickFilterValue: getPickFilterValue$4,
|
|
3072
|
+
getPickIcon: getPickIcon$4,
|
|
3073
|
+
getPickLabel: getPickLabel$4,
|
|
3074
|
+
getPicks: getPicks$4,
|
|
3075
|
+
getPlaceholder: getPlaceholder$4,
|
|
3076
|
+
getVisibleItems: getVisibleItems$4,
|
|
3077
|
+
isPrepared: isPrepared$4,
|
|
3078
|
+
name: name$4,
|
|
3079
|
+
selectPick: selectPick$4,
|
|
3080
|
+
state: state$4
|
|
3110
3081
|
};
|
|
3111
3082
|
|
|
3112
|
-
const
|
|
3113
|
-
return invoke$1(/*
|
|
3083
|
+
const getRecentlyOpened = () => {
|
|
3084
|
+
return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
3114
3085
|
};
|
|
3115
3086
|
|
|
3116
|
-
const
|
|
3117
|
-
return invoke$1(/*
|
|
3087
|
+
const openWorkspaceFolder = uri => {
|
|
3088
|
+
return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
|
|
3118
3089
|
};
|
|
3119
|
-
|
|
3120
|
-
|
|
3090
|
+
|
|
3091
|
+
const getPlaceholder$3 = () => {
|
|
3092
|
+
return selectToOpen();
|
|
3121
3093
|
};
|
|
3122
|
-
const getLabel
|
|
3123
|
-
return
|
|
3094
|
+
const getLabel = () => {
|
|
3095
|
+
return openRecent();
|
|
3124
3096
|
};
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3127
|
-
|
|
3097
|
+
const getNoResults$3 = () => {
|
|
3098
|
+
return {
|
|
3099
|
+
label: noRecentlyOpenedFoldersFound()
|
|
3100
|
+
};
|
|
3101
|
+
};
|
|
3102
|
+
|
|
3103
|
+
// TODO could also change api so that getPicks returns an array of anything
|
|
3104
|
+
// and the transformPick gets the label for each pick
|
|
3105
|
+
// This would make the code more module since the code for getting the picks
|
|
3106
|
+
// would be more independent of the specific data format of the quickpick provider
|
|
3107
|
+
|
|
3108
|
+
const getPicks$3 = async () => {
|
|
3109
|
+
const recentlyOpened = await getRecentlyOpened();
|
|
3110
|
+
return recentlyOpened;
|
|
3128
3111
|
};
|
|
3129
|
-
const getVisibleItems$
|
|
3112
|
+
const getVisibleItems$3 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
|
|
3130
3113
|
const visibleItems = picks.map((pick, index) => ({
|
|
3131
|
-
description: getPickDescription$
|
|
3132
|
-
fileIcon:
|
|
3133
|
-
icon: getPickIcon$
|
|
3114
|
+
description: getPickDescription$3(pick),
|
|
3115
|
+
fileIcon: getPickFileIcon(pick),
|
|
3116
|
+
icon: getPickIcon$3(),
|
|
3134
3117
|
isActive: index + minLineY === focusedIndex,
|
|
3135
|
-
label: getPickLabel$
|
|
3118
|
+
label: getPickLabel$3(pick),
|
|
3136
3119
|
matches: [],
|
|
3137
3120
|
posInSet: index + minLineY + 1,
|
|
3138
3121
|
setSize
|
|
3139
3122
|
}));
|
|
3140
3123
|
return visibleItems;
|
|
3141
3124
|
};
|
|
3142
|
-
|
|
3143
|
-
|
|
3125
|
+
|
|
3126
|
+
// TODO selectPick should be independent of show/hide
|
|
3127
|
+
const selectPick$3 = async pick => {
|
|
3128
|
+
const path = pick;
|
|
3129
|
+
await openWorkspaceFolder(path);
|
|
3144
3130
|
return {
|
|
3145
3131
|
command: Hide
|
|
3146
3132
|
};
|
|
3147
3133
|
};
|
|
3148
|
-
const
|
|
3149
|
-
|
|
3134
|
+
const getFilterValue$3 = value => {
|
|
3135
|
+
return pathBaseName(value);
|
|
3150
3136
|
};
|
|
3151
|
-
const
|
|
3152
|
-
return
|
|
3137
|
+
const getPickFilterValue$3 = pick => {
|
|
3138
|
+
return pathBaseName(pick);
|
|
3153
3139
|
};
|
|
3154
|
-
const
|
|
3140
|
+
const getPickLabel$3 = pick => {
|
|
3141
|
+
return pathBaseName(pick);
|
|
3142
|
+
};
|
|
3143
|
+
const getPickDescription$3 = pick => {
|
|
3144
|
+
return pathDirName(pick);
|
|
3145
|
+
};
|
|
3146
|
+
const getPickIcon$3 = () => {
|
|
3147
|
+
return '';
|
|
3148
|
+
};
|
|
3149
|
+
const getPickFileIcon = pick => {
|
|
3150
|
+
if (typeof pick === 'object') {
|
|
3151
|
+
pick = pick.pick;
|
|
3152
|
+
}
|
|
3153
|
+
if (typeof pick === 'object') {
|
|
3154
|
+
pick = pick.pick;
|
|
3155
|
+
}
|
|
3155
3156
|
return {
|
|
3156
|
-
|
|
3157
|
+
type: Directory,
|
|
3158
|
+
name: pick
|
|
3157
3159
|
};
|
|
3158
3160
|
};
|
|
3159
|
-
const
|
|
3160
|
-
|
|
3161
|
+
const state$3 = {};
|
|
3162
|
+
const isPrepared$3 = () => {
|
|
3163
|
+
return false;
|
|
3161
3164
|
};
|
|
3162
|
-
const
|
|
3163
|
-
|
|
3165
|
+
const name$3 = '';
|
|
3166
|
+
|
|
3167
|
+
const QuickPickEntriesOpenRecent = {
|
|
3168
|
+
__proto__: null,
|
|
3169
|
+
getFilterValue: getFilterValue$3,
|
|
3170
|
+
getLabel,
|
|
3171
|
+
getNoResults: getNoResults$3,
|
|
3172
|
+
getPickDescription: getPickDescription$3,
|
|
3173
|
+
getPickFileIcon,
|
|
3174
|
+
getPickFilterValue: getPickFilterValue$3,
|
|
3175
|
+
getPickIcon: getPickIcon$3,
|
|
3176
|
+
getPickLabel: getPickLabel$3,
|
|
3177
|
+
getPicks: getPicks$3,
|
|
3178
|
+
getPlaceholder: getPlaceholder$3,
|
|
3179
|
+
getVisibleItems: getVisibleItems$3,
|
|
3180
|
+
isPrepared: isPrepared$3,
|
|
3181
|
+
name: name$3,
|
|
3182
|
+
selectPick: selectPick$3,
|
|
3183
|
+
state: state$3
|
|
3164
3184
|
};
|
|
3165
|
-
|
|
3185
|
+
|
|
3186
|
+
const name$2 = 'symbol';
|
|
3187
|
+
const getPlaceholder$2 = () => {
|
|
3166
3188
|
return '';
|
|
3167
3189
|
};
|
|
3190
|
+
const getNoResults$2 = () => {
|
|
3191
|
+
return {
|
|
3192
|
+
label: noSymbolFound()
|
|
3193
|
+
};
|
|
3194
|
+
};
|
|
3195
|
+
const getPicks$2 = async () => {
|
|
3196
|
+
const picks = [];
|
|
3197
|
+
return picks;
|
|
3198
|
+
};
|
|
3199
|
+
const getVisibleItems$2 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
|
|
3200
|
+
return [];
|
|
3201
|
+
};
|
|
3202
|
+
const selectPick$2 = async item => {
|
|
3203
|
+
return {
|
|
3204
|
+
command: Hide
|
|
3205
|
+
};
|
|
3206
|
+
};
|
|
3207
|
+
const getFilterValue$2 = value => {
|
|
3208
|
+
return value;
|
|
3209
|
+
};
|
|
3168
3210
|
const state$2 = {};
|
|
3169
3211
|
const getPickDescription$2 = value => {
|
|
3170
3212
|
return '';
|
|
@@ -3172,17 +3214,19 @@ const getPickDescription$2 = value => {
|
|
|
3172
3214
|
const isPrepared$2 = () => {
|
|
3173
3215
|
return false;
|
|
3174
3216
|
};
|
|
3175
|
-
const
|
|
3176
|
-
|
|
3177
|
-
|
|
3217
|
+
const getPickFilterValue$2 = value => {
|
|
3218
|
+
return value;
|
|
3219
|
+
};
|
|
3220
|
+
const getPickLabel$2 = value => {
|
|
3221
|
+
return value;
|
|
3222
|
+
};
|
|
3223
|
+
const getPickIcon$2 = value => {
|
|
3224
|
+
return '';
|
|
3178
3225
|
};
|
|
3179
3226
|
|
|
3180
|
-
const
|
|
3227
|
+
const QuickPickEntriesSymbol = {
|
|
3181
3228
|
__proto__: null,
|
|
3182
|
-
focusPick,
|
|
3183
3229
|
getFilterValue: getFilterValue$2,
|
|
3184
|
-
getHelpEntries: getHelpEntries$1,
|
|
3185
|
-
getLabel: getLabel$2,
|
|
3186
3230
|
getNoResults: getNoResults$2,
|
|
3187
3231
|
getPickDescription: getPickDescription$2,
|
|
3188
3232
|
getPickFilterValue: getPickFilterValue$2,
|
|
@@ -3194,91 +3238,57 @@ const QuickPickEntriesColorTheme = {
|
|
|
3194
3238
|
isPrepared: isPrepared$2,
|
|
3195
3239
|
name: name$2,
|
|
3196
3240
|
selectPick: selectPick$2,
|
|
3197
|
-
setColorTheme,
|
|
3198
3241
|
state: state$2
|
|
3199
3242
|
};
|
|
3200
3243
|
|
|
3201
|
-
|
|
3202
|
-
const Cloud$1 = 'Cloud';
|
|
3203
|
-
const SourceControl$1 = 'SourceControl';
|
|
3204
|
-
const None = '';
|
|
3205
|
-
|
|
3206
|
-
const SourceControl = 1;
|
|
3207
|
-
const Cloud = 2;
|
|
3208
|
-
const Tag = 3;
|
|
3244
|
+
// TODO probably not needed
|
|
3209
3245
|
|
|
3210
|
-
const name$1 = 'custom';
|
|
3211
|
-
const state$1 = {
|
|
3212
|
-
args: []
|
|
3213
|
-
};
|
|
3214
|
-
const setArgs = args => {
|
|
3215
|
-
state$1.args = args;
|
|
3216
|
-
};
|
|
3217
3246
|
const getPlaceholder$1 = () => {
|
|
3218
|
-
return
|
|
3219
|
-
};
|
|
3220
|
-
const getLabel$1 = () => {
|
|
3221
|
-
return 'Custom';
|
|
3247
|
+
return typeNameofCommandToRun();
|
|
3222
3248
|
};
|
|
3223
|
-
|
|
3224
|
-
// TODO help entries should not be here
|
|
3225
3249
|
const getHelpEntries = () => {
|
|
3226
|
-
return
|
|
3227
|
-
};
|
|
3228
|
-
const getNoResults$1 = () => {
|
|
3229
|
-
return {
|
|
3230
|
-
label: noMatchingResults()
|
|
3231
|
-
};
|
|
3250
|
+
return undefined;
|
|
3232
3251
|
};
|
|
3233
|
-
const getPicks$1 = async
|
|
3234
|
-
const
|
|
3235
|
-
|
|
3252
|
+
const getPicks$1 = async () => {
|
|
3253
|
+
// const views = ViewService.getViews()
|
|
3254
|
+
// const picks = views.map(toPick)
|
|
3255
|
+
// return picks
|
|
3256
|
+
return [];
|
|
3236
3257
|
};
|
|
3237
|
-
const selectPick$1 = async
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
resolve(pick);
|
|
3243
|
-
return {
|
|
3244
|
-
command: Hide
|
|
3245
|
-
};
|
|
3258
|
+
const selectPick$1 = async item => {
|
|
3259
|
+
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
3260
|
+
// return {
|
|
3261
|
+
// command: QuickPickReturnValue.Hide,
|
|
3262
|
+
// }
|
|
3246
3263
|
};
|
|
3247
3264
|
const getFilterValue$1 = value => {
|
|
3248
3265
|
return value;
|
|
3249
3266
|
};
|
|
3250
|
-
const getPickFilterValue$1 =
|
|
3251
|
-
return
|
|
3252
|
-
};
|
|
3253
|
-
const getPickLabel$1 = pick => {
|
|
3254
|
-
return pick.label;
|
|
3267
|
+
const getPickFilterValue$1 = value => {
|
|
3268
|
+
return value;
|
|
3255
3269
|
};
|
|
3256
|
-
const
|
|
3257
|
-
return
|
|
3270
|
+
const getPickLabel$1 = value => {
|
|
3271
|
+
return value;
|
|
3258
3272
|
};
|
|
3259
|
-
const
|
|
3260
|
-
|
|
3261
|
-
case SourceControl:
|
|
3262
|
-
return SourceControl$1;
|
|
3263
|
-
case Cloud:
|
|
3264
|
-
return Cloud$1;
|
|
3265
|
-
case Tag:
|
|
3266
|
-
return Tag$1;
|
|
3267
|
-
default:
|
|
3268
|
-
return None;
|
|
3269
|
-
}
|
|
3273
|
+
const getPickIcon$1 = value => {
|
|
3274
|
+
return '';
|
|
3270
3275
|
};
|
|
3271
|
-
const
|
|
3272
|
-
|
|
3276
|
+
const state$1 = {};
|
|
3277
|
+
const getNoResults$1 = () => {
|
|
3278
|
+
return '';
|
|
3273
3279
|
};
|
|
3280
|
+
const name$1 = '';
|
|
3274
3281
|
const isPrepared$1 = () => {
|
|
3275
3282
|
return true;
|
|
3276
3283
|
};
|
|
3277
|
-
const
|
|
3278
|
-
|
|
3279
|
-
|
|
3284
|
+
const getPickDescription$1 = () => {
|
|
3285
|
+
return '';
|
|
3286
|
+
};
|
|
3287
|
+
const getVisibleItems$1 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
|
|
3288
|
+
const visibleItems = picks.map((pick, index) => ({
|
|
3289
|
+
description: getPickDescription$1(),
|
|
3280
3290
|
fileIcon: '',
|
|
3281
|
-
icon: getPickIcon$1(
|
|
3291
|
+
icon: getPickIcon$1(),
|
|
3282
3292
|
isActive: index + minLineY === focusedIndex,
|
|
3283
3293
|
label: getPickLabel$1(pick),
|
|
3284
3294
|
matches: [],
|
|
@@ -3288,11 +3298,10 @@ const getVisibleItems$1 = (picks, minLineY, maxLineY, focusedIndex, setSize, ico
|
|
|
3288
3298
|
return visibleItems;
|
|
3289
3299
|
};
|
|
3290
3300
|
|
|
3291
|
-
const
|
|
3301
|
+
const QuickPickEntriesView = {
|
|
3292
3302
|
__proto__: null,
|
|
3293
3303
|
getFilterValue: getFilterValue$1,
|
|
3294
3304
|
getHelpEntries,
|
|
3295
|
-
getLabel: getLabel$1,
|
|
3296
3305
|
getNoResults: getNoResults$1,
|
|
3297
3306
|
getPickDescription: getPickDescription$1,
|
|
3298
3307
|
getPickFilterValue: getPickFilterValue$1,
|
|
@@ -3304,46 +3313,53 @@ const QuickPickEntriesCustom = {
|
|
|
3304
3313
|
isPrepared: isPrepared$1,
|
|
3305
3314
|
name: name$1,
|
|
3306
3315
|
selectPick: selectPick$1,
|
|
3307
|
-
setArgs,
|
|
3308
3316
|
state: state$1
|
|
3309
3317
|
};
|
|
3310
3318
|
|
|
3311
|
-
const
|
|
3312
|
-
|
|
3319
|
+
const name = 'workspace-symbol';
|
|
3320
|
+
const getPlaceholder = () => {
|
|
3321
|
+
return '';
|
|
3313
3322
|
};
|
|
3314
|
-
|
|
3315
|
-
const
|
|
3316
|
-
return
|
|
3323
|
+
const state = {};
|
|
3324
|
+
const getPickIcon = () => {
|
|
3325
|
+
return '';
|
|
3317
3326
|
};
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
return selectToOpen();
|
|
3327
|
+
const isPrepared = () => {
|
|
3328
|
+
return false;
|
|
3321
3329
|
};
|
|
3322
|
-
const
|
|
3323
|
-
return
|
|
3330
|
+
const getPickLabel = () => {
|
|
3331
|
+
return '';
|
|
3332
|
+
};
|
|
3333
|
+
const getPickFilterValue = () => {
|
|
3334
|
+
return '';
|
|
3335
|
+
};
|
|
3336
|
+
const getPickDescription = () => {
|
|
3337
|
+
return '';
|
|
3324
3338
|
};
|
|
3325
3339
|
const getNoResults = () => {
|
|
3326
3340
|
return {
|
|
3327
|
-
label:
|
|
3341
|
+
label: noWorkspaceSymbolsFound()
|
|
3328
3342
|
};
|
|
3329
3343
|
};
|
|
3330
|
-
|
|
3331
|
-
// TODO could also change api so that getPicks returns an array of anything
|
|
3332
|
-
// and the transformPick gets the label for each pick
|
|
3333
|
-
// This would make the code more module since the code for getting the picks
|
|
3334
|
-
// would be more independent of the specific data format of the quickpick provider
|
|
3335
|
-
|
|
3336
3344
|
const getPicks = async () => {
|
|
3337
|
-
const
|
|
3338
|
-
return
|
|
3345
|
+
const picks = [];
|
|
3346
|
+
return picks;
|
|
3347
|
+
};
|
|
3348
|
+
const selectPick = async item => {
|
|
3349
|
+
return {
|
|
3350
|
+
command: Hide
|
|
3351
|
+
};
|
|
3352
|
+
};
|
|
3353
|
+
const getFilterValue = value => {
|
|
3354
|
+
return value;
|
|
3339
3355
|
};
|
|
3340
3356
|
const getVisibleItems = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
|
|
3341
3357
|
const visibleItems = picks.map((pick, index) => ({
|
|
3342
|
-
description:
|
|
3343
|
-
fileIcon:
|
|
3344
|
-
icon:
|
|
3358
|
+
description: '',
|
|
3359
|
+
fileIcon: '',
|
|
3360
|
+
icon: '',
|
|
3345
3361
|
isActive: index + minLineY === focusedIndex,
|
|
3346
|
-
label:
|
|
3362
|
+
label: pick.label || '',
|
|
3347
3363
|
matches: [],
|
|
3348
3364
|
posInSet: index + minLineY + 1,
|
|
3349
3365
|
setSize
|
|
@@ -3351,54 +3367,11 @@ const getVisibleItems = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
|
|
|
3351
3367
|
return visibleItems;
|
|
3352
3368
|
};
|
|
3353
3369
|
|
|
3354
|
-
|
|
3355
|
-
const selectPick = async pick => {
|
|
3356
|
-
const path = pick;
|
|
3357
|
-
await openWorkspaceFolder(path);
|
|
3358
|
-
return {
|
|
3359
|
-
command: Hide
|
|
3360
|
-
};
|
|
3361
|
-
};
|
|
3362
|
-
const getFilterValue = value => {
|
|
3363
|
-
return pathBaseName(value);
|
|
3364
|
-
};
|
|
3365
|
-
const getPickFilterValue = pick => {
|
|
3366
|
-
return pathBaseName(pick);
|
|
3367
|
-
};
|
|
3368
|
-
const getPickLabel = pick => {
|
|
3369
|
-
return pathBaseName(pick);
|
|
3370
|
-
};
|
|
3371
|
-
const getPickDescription = pick => {
|
|
3372
|
-
return pathDirName(pick);
|
|
3373
|
-
};
|
|
3374
|
-
const getPickIcon = () => {
|
|
3375
|
-
return '';
|
|
3376
|
-
};
|
|
3377
|
-
const getPickFileIcon = pick => {
|
|
3378
|
-
if (typeof pick === 'object') {
|
|
3379
|
-
pick = pick.pick;
|
|
3380
|
-
}
|
|
3381
|
-
if (typeof pick === 'object') {
|
|
3382
|
-
pick = pick.pick;
|
|
3383
|
-
}
|
|
3384
|
-
return {
|
|
3385
|
-
type: Directory,
|
|
3386
|
-
name: pick
|
|
3387
|
-
};
|
|
3388
|
-
};
|
|
3389
|
-
const state = {};
|
|
3390
|
-
const isPrepared = () => {
|
|
3391
|
-
return false;
|
|
3392
|
-
};
|
|
3393
|
-
const name = '';
|
|
3394
|
-
|
|
3395
|
-
const QuickPickEntriesOpenRecent = {
|
|
3370
|
+
const QuickPickEntriesWorkspaceSymbol = {
|
|
3396
3371
|
__proto__: null,
|
|
3397
3372
|
getFilterValue,
|
|
3398
|
-
getLabel,
|
|
3399
3373
|
getNoResults,
|
|
3400
3374
|
getPickDescription,
|
|
3401
|
-
getPickFileIcon,
|
|
3402
3375
|
getPickFilterValue,
|
|
3403
3376
|
getPickIcon,
|
|
3404
3377
|
getPickLabel,
|
|
@@ -3411,28 +3384,17 @@ const QuickPickEntriesOpenRecent = {
|
|
|
3411
3384
|
state
|
|
3412
3385
|
};
|
|
3413
3386
|
|
|
3414
|
-
const CommandPalette = 'quickPick://commandPalette';
|
|
3415
|
-
const Commands = 'quickPick://commands';
|
|
3416
|
-
const File$1 = 'quickPick://file';
|
|
3417
|
-
const EveryThing = 'quickPick://everything';
|
|
3418
|
-
const Recent = 'quickPick://recent';
|
|
3419
|
-
const ColorTheme = 'quickPick://color-theme';
|
|
3420
|
-
const Symbol = 'quickPick://symbol';
|
|
3421
|
-
const View = 'quickPick://view';
|
|
3422
|
-
const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
3423
|
-
const Custom = 'quickPick://custom';
|
|
3424
|
-
|
|
3425
3387
|
const quickPickEntriesModules = {
|
|
3388
|
+
[ColorTheme]: QuickPickEntriesColorTheme,
|
|
3426
3389
|
[CommandPalette]: QuickPickEntriesEverything,
|
|
3427
|
-
[Commands]:
|
|
3428
|
-
[
|
|
3390
|
+
[Commands]: QuickPickEntriesCommand,
|
|
3391
|
+
[Custom]: QuickPickEntriesCustom,
|
|
3429
3392
|
[EveryThing]: QuickPickEntriesEverything,
|
|
3430
|
-
[
|
|
3393
|
+
[File$2]: QuickPickEntriesFile,
|
|
3431
3394
|
[Recent]: QuickPickEntriesOpenRecent,
|
|
3432
|
-
[ColorTheme]: QuickPickEntriesColorTheme,
|
|
3433
3395
|
[Symbol]: QuickPickEntriesSymbol,
|
|
3434
3396
|
[View]: QuickPickEntriesView,
|
|
3435
|
-
[
|
|
3397
|
+
[WorkspaceSymbol]: QuickPickEntriesWorkspaceSymbol
|
|
3436
3398
|
};
|
|
3437
3399
|
|
|
3438
3400
|
const Memfs = 'memfs';
|
|
@@ -3499,8 +3461,8 @@ const searchModules = {
|
|
|
3499
3461
|
};
|
|
3500
3462
|
|
|
3501
3463
|
const listen = async () => {
|
|
3502
|
-
register
|
|
3503
|
-
register(quickPickEntriesModules);
|
|
3464
|
+
register(searchModules);
|
|
3465
|
+
register$1(quickPickEntriesModules);
|
|
3504
3466
|
const rpc = await WebWorkerRpcClient.create({
|
|
3505
3467
|
commandMap: commandMap
|
|
3506
3468
|
});
|