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