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