@lvce-editor/text-search-worker 2.3.0 → 2.5.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/textSearchWorkerMain.js +1261 -717
- package/package.json +7 -3
|
@@ -18,221 +18,31 @@ const execute = (command, ...args) => {
|
|
|
18
18
|
return fn(...args);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const User = 1;
|
|
24
|
-
const Script = 2;
|
|
25
|
-
|
|
26
|
-
const minimumSliderSize = 20;
|
|
27
|
-
|
|
28
|
-
const states = Object.create(null);
|
|
29
|
-
const get$2 = uid => {
|
|
30
|
-
return states[uid];
|
|
31
|
-
};
|
|
32
|
-
const set$2 = (uid, state) => {
|
|
33
|
-
states[uid] = state;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const create$5 = ({
|
|
37
|
-
itemHeight,
|
|
38
|
-
headerHeight = 0,
|
|
39
|
-
minimumSliderSize = 20
|
|
40
|
-
}) => {
|
|
21
|
+
const clearSearchResults$1 = state => {
|
|
41
22
|
return {
|
|
42
|
-
|
|
23
|
+
...state,
|
|
24
|
+
value: '',
|
|
25
|
+
items: [],
|
|
43
26
|
minLineY: 0,
|
|
44
27
|
maxLineY: 0,
|
|
45
|
-
|
|
46
|
-
itemHeight,
|
|
47
|
-
headerHeight,
|
|
48
|
-
items: [],
|
|
49
|
-
minimumSliderSize,
|
|
50
|
-
focusedIndex: -1,
|
|
51
|
-
touchOffsetY: 0,
|
|
52
|
-
touchTimeStamp: 0,
|
|
53
|
-
touchDifference: 0,
|
|
54
|
-
scrollBarHeight: 0,
|
|
55
|
-
scrollBarActive: false
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const Empty$1 = 0;
|
|
60
|
-
const FocusSearchInput = 21;
|
|
61
|
-
const FocusSearchReplaceInput = 31;
|
|
62
|
-
const FocusSearchMatchCase = 32;
|
|
63
|
-
const FocusSearchRegex = 33;
|
|
64
|
-
const FocusSearchWholeWord = 34;
|
|
65
|
-
const FocusSearchReplaceAll = 35;
|
|
66
|
-
const FocusSearchPreserveCase = 36;
|
|
67
|
-
|
|
68
|
-
const create$4 = (uid, x, y, width, height, workspacePath) => {
|
|
69
|
-
const state = {
|
|
70
|
-
uid,
|
|
71
|
-
searchResults: [],
|
|
72
|
-
stats: {},
|
|
73
|
-
searchId: -1,
|
|
74
|
-
value: '',
|
|
75
|
-
disposed: false,
|
|
76
|
-
fileCount: 0,
|
|
77
|
-
x,
|
|
78
|
-
y,
|
|
79
|
-
width,
|
|
80
|
-
height,
|
|
81
|
-
...create$5({
|
|
82
|
-
itemHeight: ListItem,
|
|
83
|
-
minimumSliderSize: minimumSliderSize,
|
|
84
|
-
headerHeight: 61 // TODO
|
|
85
|
-
}),
|
|
86
|
-
threads: 0,
|
|
87
|
-
replaceExpanded: false,
|
|
88
|
-
useRegularExpression: false,
|
|
89
|
-
matchCase: false,
|
|
90
|
-
matchWholeWord: false,
|
|
91
|
-
replacement: '',
|
|
92
|
-
matchCount: 0,
|
|
93
|
-
listFocused: false,
|
|
94
|
-
listFocusedIndex: -1,
|
|
95
|
-
inputSource: User,
|
|
96
|
-
workspacePath: workspacePath,
|
|
97
|
-
includeValue: '',
|
|
98
|
-
excludeValue: '',
|
|
99
|
-
detailsExpanded: false,
|
|
100
|
-
focus: Empty$1,
|
|
101
|
-
loaded: false,
|
|
102
|
-
message: '',
|
|
103
|
-
collapsedPaths: []
|
|
104
|
-
};
|
|
105
|
-
set$2(uid, state);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const focusMatchCase$1 = state => {
|
|
109
|
-
return {
|
|
110
|
-
...state,
|
|
111
|
-
focus: FocusSearchMatchCase
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const focusReplaceValue$1 = state => {
|
|
116
|
-
return {
|
|
117
|
-
...state,
|
|
118
|
-
focus: FocusSearchReplaceInput
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const focusSearchValue$1 = state => {
|
|
123
|
-
return {
|
|
124
|
-
...state,
|
|
125
|
-
focus: FocusSearchInput
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const focusSearchValueNext$1 = state => {
|
|
130
|
-
const {
|
|
131
|
-
replaceExpanded
|
|
132
|
-
} = state;
|
|
133
|
-
if (replaceExpanded) {
|
|
134
|
-
return focusReplaceValue$1(state);
|
|
135
|
-
}
|
|
136
|
-
return focusMatchCase$1(state);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const CheckBox = 'checkbox';
|
|
140
|
-
const None = 'none';
|
|
141
|
-
const Status = 'status';
|
|
142
|
-
const Tree = 'tree';
|
|
143
|
-
const TreeItem$1 = 'treeitem';
|
|
144
|
-
const ToolBar = 'toolbar';
|
|
145
|
-
|
|
146
|
-
const Chevron = 'Chevron';
|
|
147
|
-
const CloseMaskIcon = 'MaskIcon MaskIconClose';
|
|
148
|
-
const Empty = '';
|
|
149
|
-
const FileIcon = 'FileIcon';
|
|
150
|
-
const IconButton = 'IconButton';
|
|
151
|
-
const Actions = 'Actions';
|
|
152
|
-
const FocusOutline = 'FocusOutline';
|
|
153
|
-
const Highlight = 'Highlight';
|
|
154
|
-
const HighlightDeleted = 'HighlightDeleted';
|
|
155
|
-
const HighlightInserted = 'HighlightInserted';
|
|
156
|
-
const Label = 'Label';
|
|
157
|
-
const List = 'List';
|
|
158
|
-
const MaskIcon = 'MaskIcon';
|
|
159
|
-
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
160
|
-
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
161
|
-
const MultilineInputBox = 'MultilineInputBox';
|
|
162
|
-
const Search$1 = 'Search';
|
|
163
|
-
const SearchField = 'SearchField';
|
|
164
|
-
const SearchFieldButtons = 'SearchFieldButtons';
|
|
165
|
-
const SearchFieldContainer = 'SearchFieldContainer';
|
|
166
|
-
const SearchHeader = 'SearchHeader';
|
|
167
|
-
const SearchHeaderTop = 'SearchHeaderTop';
|
|
168
|
-
const SearchRemove = 'SearchRemove';
|
|
169
|
-
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
170
|
-
const SourceControlBadge = 'SourceControlBadge';
|
|
171
|
-
const TreeItem = 'TreeItem';
|
|
172
|
-
const TreeItemActive = 'TreeItemActive';
|
|
173
|
-
const Viewlet = 'Viewlet';
|
|
174
|
-
const ViewletSearchMessage = 'ViewletSearchMessage';
|
|
175
|
-
|
|
176
|
-
const Button$1 = 1;
|
|
177
|
-
|
|
178
|
-
const Button = 1;
|
|
179
|
-
const Div = 4;
|
|
180
|
-
const Input = 6;
|
|
181
|
-
const Span = 8;
|
|
182
|
-
const Text = 12;
|
|
183
|
-
const Img = 17;
|
|
184
|
-
const Ins = 20;
|
|
185
|
-
const Del = 21;
|
|
186
|
-
const TextArea = 62;
|
|
187
|
-
|
|
188
|
-
const getIconVirtualDom = (icon, type = Div) => {
|
|
189
|
-
return {
|
|
190
|
-
type,
|
|
191
|
-
className: `MaskIcon MaskIcon${icon}`,
|
|
192
|
-
role: None,
|
|
193
|
-
childCount: 0
|
|
28
|
+
message: ''
|
|
194
29
|
};
|
|
195
30
|
};
|
|
196
31
|
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
} = action;
|
|
203
|
-
return [{
|
|
204
|
-
type: Button,
|
|
205
|
-
className: IconButton,
|
|
206
|
-
title: id,
|
|
207
|
-
'data-command': command,
|
|
208
|
-
childCount: 1
|
|
209
|
-
}, getIconVirtualDom(icon)];
|
|
32
|
+
const state$3 = {
|
|
33
|
+
/**
|
|
34
|
+
* @type {any}
|
|
35
|
+
*/
|
|
36
|
+
ipc: undefined
|
|
210
37
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
switch (action.type) {
|
|
214
|
-
case Button$1:
|
|
215
|
-
return getActionButtonVirtualDom(action);
|
|
216
|
-
default:
|
|
217
|
-
return [];
|
|
218
|
-
}
|
|
38
|
+
const get$2 = () => {
|
|
39
|
+
return state$3.ipc;
|
|
219
40
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return [{
|
|
223
|
-
type: Div,
|
|
224
|
-
className: Actions,
|
|
225
|
-
role: ToolBar,
|
|
226
|
-
childCount: actions.length
|
|
227
|
-
}, ...actions.flatMap(getActionVirtualDom)];
|
|
41
|
+
const set$2 = ipc => {
|
|
42
|
+
state$3.ipc = ipc;
|
|
228
43
|
};
|
|
229
44
|
|
|
230
|
-
const
|
|
231
|
-
const CollapseAll = 'CollapseAll';
|
|
232
|
-
const ListFlat = 'ListFlat';
|
|
233
|
-
const NewFile = 'NewFile';
|
|
234
|
-
const Refresh = 'Refresh';
|
|
235
|
-
|
|
45
|
+
const Two = '2.0';
|
|
236
46
|
let AssertionError$1 = class AssertionError extends Error {
|
|
237
47
|
constructor(message) {
|
|
238
48
|
super(message);
|
|
@@ -267,30 +77,528 @@ const number$1 = value => {
|
|
|
267
77
|
throw new AssertionError$1('expected value to be of type number');
|
|
268
78
|
}
|
|
269
79
|
};
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
if (type !== 'string') {
|
|
273
|
-
throw new AssertionError$1('expected value to be of type string');
|
|
274
|
-
}
|
|
80
|
+
const state$1 = {
|
|
81
|
+
callbacks: Object.create(null)
|
|
275
82
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
83
|
+
const set$1 = (id, fn) => {
|
|
84
|
+
state$1.callbacks[id] = fn;
|
|
85
|
+
};
|
|
86
|
+
const get$1 = id => {
|
|
87
|
+
return state$1.callbacks[id];
|
|
88
|
+
};
|
|
89
|
+
const remove$1 = id => {
|
|
90
|
+
delete state$1.callbacks[id];
|
|
91
|
+
};
|
|
92
|
+
const state$2 = {
|
|
93
|
+
id: 0
|
|
94
|
+
};
|
|
95
|
+
const create$3 = () => {
|
|
96
|
+
return ++state$2.id;
|
|
97
|
+
};
|
|
98
|
+
const warn = (...args) => {
|
|
99
|
+
console.warn(...args);
|
|
100
|
+
};
|
|
101
|
+
const registerPromise = () => {
|
|
102
|
+
const id = create$3();
|
|
103
|
+
const {
|
|
104
|
+
resolve,
|
|
105
|
+
promise
|
|
106
|
+
} = Promise.withResolvers();
|
|
107
|
+
set$1(id, resolve);
|
|
108
|
+
return {
|
|
109
|
+
id,
|
|
110
|
+
promise
|
|
286
111
|
};
|
|
287
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
288
112
|
};
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
113
|
+
const resolve = (id, args) => {
|
|
114
|
+
number$1(id);
|
|
115
|
+
const fn = get$1(id);
|
|
116
|
+
if (!fn) {
|
|
117
|
+
console.log(args);
|
|
118
|
+
warn(`callback ${id} may already be disposed`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
fn(args);
|
|
122
|
+
remove$1(id);
|
|
123
|
+
};
|
|
124
|
+
const create$2 = (method, params) => {
|
|
125
|
+
const {
|
|
126
|
+
id,
|
|
127
|
+
promise
|
|
128
|
+
} = registerPromise();
|
|
129
|
+
const message = {
|
|
130
|
+
jsonrpc: Two,
|
|
131
|
+
method,
|
|
132
|
+
params,
|
|
133
|
+
id
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
message,
|
|
137
|
+
promise
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
class JsonRpcError extends Error {
|
|
141
|
+
constructor(message) {
|
|
142
|
+
super(message);
|
|
143
|
+
this.name = 'JsonRpcError';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const NewLine$3 = '\n';
|
|
147
|
+
const DomException = 'DOMException';
|
|
148
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
149
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
150
|
+
const TypeError$1 = 'TypeError';
|
|
151
|
+
const getErrorConstructor = (message, type) => {
|
|
152
|
+
if (type) {
|
|
153
|
+
switch (type) {
|
|
154
|
+
case DomException:
|
|
155
|
+
return DOMException;
|
|
156
|
+
case TypeError$1:
|
|
157
|
+
return TypeError;
|
|
158
|
+
case SyntaxError$1:
|
|
159
|
+
return SyntaxError;
|
|
160
|
+
case ReferenceError$1:
|
|
161
|
+
return ReferenceError;
|
|
162
|
+
default:
|
|
163
|
+
return Error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (message.startsWith('TypeError: ')) {
|
|
167
|
+
return TypeError;
|
|
168
|
+
}
|
|
169
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
170
|
+
return SyntaxError;
|
|
171
|
+
}
|
|
172
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
173
|
+
return ReferenceError;
|
|
174
|
+
}
|
|
175
|
+
return Error;
|
|
176
|
+
};
|
|
177
|
+
const constructError = (message, type, name) => {
|
|
178
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
179
|
+
if (ErrorConstructor === DOMException && name) {
|
|
180
|
+
return new ErrorConstructor(message, name);
|
|
181
|
+
}
|
|
182
|
+
if (ErrorConstructor === Error) {
|
|
183
|
+
const error = new Error(message);
|
|
184
|
+
if (name && name !== 'VError') {
|
|
185
|
+
error.name = name;
|
|
186
|
+
}
|
|
187
|
+
return error;
|
|
188
|
+
}
|
|
189
|
+
return new ErrorConstructor(message);
|
|
190
|
+
};
|
|
191
|
+
const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
192
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
193
|
+
};
|
|
194
|
+
const getParentStack = error => {
|
|
195
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
196
|
+
if (parentStack.startsWith(' at')) {
|
|
197
|
+
parentStack = error.message + NewLine$3 + parentStack;
|
|
198
|
+
}
|
|
199
|
+
return parentStack;
|
|
200
|
+
};
|
|
201
|
+
const joinLines$1 = lines => {
|
|
202
|
+
return lines.join(NewLine$3);
|
|
203
|
+
};
|
|
204
|
+
const MethodNotFound = -32601;
|
|
205
|
+
const Custom = -32001;
|
|
206
|
+
const splitLines$2 = lines => {
|
|
207
|
+
return lines.split(NewLine$3);
|
|
208
|
+
};
|
|
209
|
+
const restoreJsonRpcError = error => {
|
|
210
|
+
if (error && error instanceof Error) {
|
|
211
|
+
return error;
|
|
212
|
+
}
|
|
213
|
+
const currentStack = joinLines$1(splitLines$2(new Error().stack || '').slice(1));
|
|
214
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
215
|
+
const restoredError = new JsonRpcError(error.message);
|
|
216
|
+
const parentStack = getParentStack(error);
|
|
217
|
+
restoredError.stack = parentStack + NewLine$3 + currentStack;
|
|
218
|
+
return restoredError;
|
|
219
|
+
}
|
|
220
|
+
if (error && error.message) {
|
|
221
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
222
|
+
if (error.data) {
|
|
223
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
224
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$3 + error.data.stack + NewLine$3 + currentStack;
|
|
225
|
+
} else if (error.data.stack) {
|
|
226
|
+
restoredError.stack = error.data.stack;
|
|
227
|
+
}
|
|
228
|
+
if (error.data.codeFrame) {
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
231
|
+
}
|
|
232
|
+
if (error.data.code) {
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
restoredError.code = error.data.code;
|
|
235
|
+
}
|
|
236
|
+
if (error.data.type) {
|
|
237
|
+
// @ts-ignore
|
|
238
|
+
restoredError.name = error.data.type;
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
if (error.stack) {
|
|
242
|
+
const lowerStack = restoredError.stack || '';
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
const indexNewLine = getNewLineIndex$2(lowerStack);
|
|
245
|
+
const parentStack = getParentStack(error);
|
|
246
|
+
// @ts-ignore
|
|
247
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
248
|
+
}
|
|
249
|
+
if (error.codeFrame) {
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
restoredError.codeFrame = error.codeFrame;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return restoredError;
|
|
255
|
+
}
|
|
256
|
+
if (typeof error === 'string') {
|
|
257
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
258
|
+
}
|
|
259
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
260
|
+
};
|
|
261
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
262
|
+
if ('error' in responseMessage) {
|
|
263
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
264
|
+
throw restoredError;
|
|
265
|
+
}
|
|
266
|
+
if ('result' in responseMessage) {
|
|
267
|
+
return responseMessage.result;
|
|
268
|
+
}
|
|
269
|
+
throw new JsonRpcError('unexpected response message');
|
|
270
|
+
};
|
|
271
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
272
|
+
const getErrorType = prettyError => {
|
|
273
|
+
if (prettyError && prettyError.type) {
|
|
274
|
+
return prettyError.type;
|
|
275
|
+
}
|
|
276
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
277
|
+
return prettyError.constructor.name;
|
|
278
|
+
}
|
|
279
|
+
return undefined;
|
|
280
|
+
};
|
|
281
|
+
const getErrorProperty = (error, prettyError) => {
|
|
282
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
283
|
+
return {
|
|
284
|
+
code: MethodNotFound,
|
|
285
|
+
message: error.message,
|
|
286
|
+
data: error.stack
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
code: Custom,
|
|
291
|
+
message: prettyError.message,
|
|
292
|
+
data: {
|
|
293
|
+
stack: prettyError.stack,
|
|
294
|
+
codeFrame: prettyError.codeFrame,
|
|
295
|
+
type: getErrorType(prettyError),
|
|
296
|
+
code: prettyError.code,
|
|
297
|
+
name: prettyError.name
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
const create$1$1 = (message, error) => {
|
|
302
|
+
return {
|
|
303
|
+
jsonrpc: Two,
|
|
304
|
+
id: message.id,
|
|
305
|
+
error
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
309
|
+
const prettyError = preparePrettyError(error);
|
|
310
|
+
logError(error, prettyError);
|
|
311
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
312
|
+
return create$1$1(message, errorProperty);
|
|
313
|
+
};
|
|
314
|
+
const create$4 = (message, result) => {
|
|
315
|
+
return {
|
|
316
|
+
jsonrpc: Two,
|
|
317
|
+
id: message.id,
|
|
318
|
+
result: result ?? null
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
const getSuccessResponse = (message, result) => {
|
|
322
|
+
const resultProperty = result ?? null;
|
|
323
|
+
return create$4(message, resultProperty);
|
|
324
|
+
};
|
|
325
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
326
|
+
try {
|
|
327
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
328
|
+
return getSuccessResponse(message, result);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
const defaultPreparePrettyError = error => {
|
|
334
|
+
return error;
|
|
335
|
+
};
|
|
336
|
+
const defaultLogError = () => {
|
|
337
|
+
// ignore
|
|
338
|
+
};
|
|
339
|
+
const defaultRequiresSocket = () => {
|
|
340
|
+
return false;
|
|
341
|
+
};
|
|
342
|
+
const defaultResolve = resolve;
|
|
343
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
344
|
+
let message;
|
|
345
|
+
let ipc;
|
|
346
|
+
let execute;
|
|
347
|
+
let preparePrettyError;
|
|
348
|
+
let logError;
|
|
349
|
+
let resolve;
|
|
350
|
+
let requiresSocket;
|
|
351
|
+
if (args.length === 1) {
|
|
352
|
+
const arg = args[0];
|
|
353
|
+
message = arg.message;
|
|
354
|
+
ipc = arg.ipc;
|
|
355
|
+
execute = arg.execute;
|
|
356
|
+
preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
|
|
357
|
+
logError = arg.logError || defaultLogError;
|
|
358
|
+
requiresSocket = arg.requiresSocket || defaultRequiresSocket;
|
|
359
|
+
resolve = arg.resolve || defaultResolve;
|
|
360
|
+
} else {
|
|
361
|
+
ipc = args[0];
|
|
362
|
+
message = args[1];
|
|
363
|
+
execute = args[2];
|
|
364
|
+
resolve = args[3];
|
|
365
|
+
preparePrettyError = args[4];
|
|
366
|
+
logError = args[5];
|
|
367
|
+
requiresSocket = args[6];
|
|
368
|
+
}
|
|
369
|
+
if ('id' in message) {
|
|
370
|
+
if ('method' in message) {
|
|
371
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
372
|
+
try {
|
|
373
|
+
ipc.send(response);
|
|
374
|
+
} catch (error) {
|
|
375
|
+
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
376
|
+
ipc.send(errorResponse);
|
|
377
|
+
}
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
resolve(message.id, message);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if ('method' in message) {
|
|
384
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
throw new JsonRpcError('unexpected message');
|
|
388
|
+
};
|
|
389
|
+
const invoke$2 = async (ipc, method, ...params) => {
|
|
390
|
+
const {
|
|
391
|
+
message,
|
|
392
|
+
promise
|
|
393
|
+
} = create$2(method, params);
|
|
394
|
+
ipc.send(message);
|
|
395
|
+
const responseMessage = await promise;
|
|
396
|
+
const result = unwrapJsonRpcResult(responseMessage);
|
|
397
|
+
return result;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const invoke$1 = (method, ...params) => {
|
|
401
|
+
const ipc = get$2();
|
|
402
|
+
return invoke$2(ipc, method, ...params);
|
|
403
|
+
};
|
|
404
|
+
const listen$2 = ipc => {
|
|
405
|
+
set$2(ipc);
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
const copy = async state => {
|
|
409
|
+
const {
|
|
410
|
+
items,
|
|
411
|
+
listFocusedIndex
|
|
412
|
+
} = state;
|
|
413
|
+
if (listFocusedIndex === -1) {
|
|
414
|
+
return state;
|
|
415
|
+
}
|
|
416
|
+
const item = items[listFocusedIndex];
|
|
417
|
+
await invoke$1('ClipBoard.writeText', item.text);
|
|
418
|
+
return state;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const ListItem = 22;
|
|
422
|
+
|
|
423
|
+
const User = 1;
|
|
424
|
+
const Script = 2;
|
|
425
|
+
|
|
426
|
+
const minimumSliderSize = 20;
|
|
427
|
+
|
|
428
|
+
const states = Object.create(null);
|
|
429
|
+
const get = uid => {
|
|
430
|
+
return states[uid];
|
|
431
|
+
};
|
|
432
|
+
const set = (uid, state) => {
|
|
433
|
+
states[uid] = state;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
const create$1 = ({
|
|
437
|
+
itemHeight,
|
|
438
|
+
headerHeight = 0,
|
|
439
|
+
minimumSliderSize = 20
|
|
440
|
+
}) => {
|
|
441
|
+
return {
|
|
442
|
+
deltaY: 0,
|
|
443
|
+
minLineY: 0,
|
|
444
|
+
maxLineY: 0,
|
|
445
|
+
finalDeltaY: 0,
|
|
446
|
+
itemHeight,
|
|
447
|
+
headerHeight,
|
|
448
|
+
items: [],
|
|
449
|
+
minimumSliderSize,
|
|
450
|
+
focusedIndex: -1,
|
|
451
|
+
touchOffsetY: 0,
|
|
452
|
+
touchTimeStamp: 0,
|
|
453
|
+
touchDifference: 0,
|
|
454
|
+
scrollBarHeight: 0,
|
|
455
|
+
scrollBarActive: false
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const Empty$1 = 0;
|
|
460
|
+
const FocusSearchInput = 21;
|
|
461
|
+
const FocusSearchReplaceInput = 31;
|
|
462
|
+
const FocusSearchMatchCase = 32;
|
|
463
|
+
const FocusSearchRegex = 33;
|
|
464
|
+
const FocusSearchWholeWord = 34;
|
|
465
|
+
const FocusSearchReplaceAll = 35;
|
|
466
|
+
const FocusSearchPreserveCase = 36;
|
|
467
|
+
|
|
468
|
+
const create = (uid, x, y, width, height, workspacePath) => {
|
|
469
|
+
const state = {
|
|
470
|
+
uid,
|
|
471
|
+
searchResults: [],
|
|
472
|
+
stats: {},
|
|
473
|
+
searchId: -1,
|
|
474
|
+
value: '',
|
|
475
|
+
disposed: false,
|
|
476
|
+
fileCount: 0,
|
|
477
|
+
x,
|
|
478
|
+
y,
|
|
479
|
+
width,
|
|
480
|
+
height,
|
|
481
|
+
...create$1({
|
|
482
|
+
itemHeight: ListItem,
|
|
483
|
+
minimumSliderSize: minimumSliderSize,
|
|
484
|
+
headerHeight: 61 // TODO
|
|
485
|
+
}),
|
|
486
|
+
threads: 0,
|
|
487
|
+
replaceExpanded: false,
|
|
488
|
+
useRegularExpression: false,
|
|
489
|
+
matchCase: false,
|
|
490
|
+
matchWholeWord: false,
|
|
491
|
+
replacement: '',
|
|
492
|
+
matchCount: 0,
|
|
493
|
+
listFocused: false,
|
|
494
|
+
listFocusedIndex: -1,
|
|
495
|
+
inputSource: User,
|
|
496
|
+
workspacePath: workspacePath,
|
|
497
|
+
includeValue: '',
|
|
498
|
+
excludeValue: '',
|
|
499
|
+
detailsExpanded: false,
|
|
500
|
+
focus: Empty$1,
|
|
501
|
+
loaded: false,
|
|
502
|
+
message: '',
|
|
503
|
+
collapsedPaths: []
|
|
504
|
+
};
|
|
505
|
+
set(uid, state);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
509
|
+
|
|
510
|
+
const insertInto = (array, start, newItems) => {
|
|
511
|
+
const originalLength = array.length;
|
|
512
|
+
const newItemsLength = newItems.length;
|
|
513
|
+
array.length = originalLength + newItemsLength;
|
|
514
|
+
// Move the items after the start index, start from the end so that we don't overwrite any value.
|
|
515
|
+
for (let i = originalLength - 1; i >= start; i--) {
|
|
516
|
+
array[i + newItemsLength] = array[i];
|
|
517
|
+
}
|
|
518
|
+
for (let i = 0; i < newItemsLength; i++) {
|
|
519
|
+
array[i + start] = newItems[i];
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
const push = (array, newItems) => {
|
|
523
|
+
insertInto(array, array.length, newItems);
|
|
524
|
+
};
|
|
525
|
+
const isLastIndex = (array, index) => {
|
|
526
|
+
return index === array.length - 1;
|
|
527
|
+
};
|
|
528
|
+
const lastIndex = array => {
|
|
529
|
+
return array.length - 1;
|
|
530
|
+
};
|
|
531
|
+
const toSpliced = (array, index, deleteCount, ...inserted) => {
|
|
532
|
+
return [...array.slice(0, index), ...inserted, ...array.slice(index + deleteCount)];
|
|
533
|
+
};
|
|
534
|
+
const remove = (array, index, deleteCount) => {
|
|
535
|
+
return toSpliced(array, index, deleteCount);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
class AssertionError extends Error {
|
|
539
|
+
constructor(message) {
|
|
540
|
+
super(message);
|
|
541
|
+
this.name = 'AssertionError';
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const getType = value => {
|
|
545
|
+
switch (typeof value) {
|
|
546
|
+
case 'number':
|
|
547
|
+
return 'number';
|
|
548
|
+
case 'function':
|
|
549
|
+
return 'function';
|
|
550
|
+
case 'string':
|
|
551
|
+
return 'string';
|
|
552
|
+
case 'object':
|
|
553
|
+
if (value === null) {
|
|
554
|
+
return 'null';
|
|
555
|
+
}
|
|
556
|
+
if (Array.isArray(value)) {
|
|
557
|
+
return 'array';
|
|
558
|
+
}
|
|
559
|
+
return 'object';
|
|
560
|
+
case 'boolean':
|
|
561
|
+
return 'boolean';
|
|
562
|
+
default:
|
|
563
|
+
return 'unknown';
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const object = value => {
|
|
567
|
+
const type = getType(value);
|
|
568
|
+
if (type !== 'object') {
|
|
569
|
+
throw new AssertionError('expected value to be of type object');
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const number = value => {
|
|
573
|
+
const type = getType(value);
|
|
574
|
+
if (type !== 'number') {
|
|
575
|
+
throw new AssertionError('expected value to be of type number');
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
const string = value => {
|
|
579
|
+
const type = getType(value);
|
|
580
|
+
if (type !== 'string') {
|
|
581
|
+
throw new AssertionError('expected value to be of type string');
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
const emptyObject = {};
|
|
586
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
587
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
588
|
+
if (placeholders === emptyObject) {
|
|
589
|
+
return key;
|
|
590
|
+
}
|
|
591
|
+
const replacer = (match, rest) => {
|
|
592
|
+
// @ts-ignore
|
|
593
|
+
return placeholders[rest];
|
|
594
|
+
};
|
|
595
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* @enum {string}
|
|
600
|
+
*/
|
|
601
|
+
const UiStrings = {
|
|
294
602
|
NoResults: 'No results found',
|
|
295
603
|
Oneresult: '1 result in 1 file',
|
|
296
604
|
ManyResultsInOneFile: '{PH1} results in 1 file',
|
|
@@ -332,26 +640,299 @@ const manyResultsInManyFiles = (resultCount, fileResultCount) => {
|
|
|
332
640
|
PH2: fileResultCount
|
|
333
641
|
});
|
|
334
642
|
};
|
|
335
|
-
const refresh = () => {
|
|
643
|
+
const refresh$1 = () => {
|
|
336
644
|
return i18nString(UiStrings.Refresh);
|
|
337
645
|
};
|
|
338
646
|
const clearSearchResults = () => {
|
|
339
647
|
return i18nString(UiStrings.ClearSearchResults);
|
|
340
648
|
};
|
|
341
|
-
const openNewSearchEditor = () => {
|
|
342
|
-
return i18nString(UiStrings.OpenNewSearchEditor);
|
|
649
|
+
const openNewSearchEditor = () => {
|
|
650
|
+
return i18nString(UiStrings.OpenNewSearchEditor);
|
|
651
|
+
};
|
|
652
|
+
const viewAsTree = () => {
|
|
653
|
+
return i18nString(UiStrings.ViewAsTree);
|
|
654
|
+
};
|
|
655
|
+
const collapseAll = () => {
|
|
656
|
+
return i18nString(UiStrings.CollapseAll);
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
const getStatusMessage = (resultCount, fileResultCount) => {
|
|
660
|
+
number(resultCount);
|
|
661
|
+
number(fileResultCount);
|
|
662
|
+
if (resultCount === 0) {
|
|
663
|
+
return noResults();
|
|
664
|
+
}
|
|
665
|
+
if (resultCount === 1) {
|
|
666
|
+
return oneResult();
|
|
667
|
+
}
|
|
668
|
+
if (fileResultCount === 1) {
|
|
669
|
+
return manyResultsInOneFile(resultCount);
|
|
670
|
+
}
|
|
671
|
+
return manyResultsInManyFiles(resultCount, fileResultCount);
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
const File$1 = 1;
|
|
675
|
+
const Match = 2;
|
|
676
|
+
|
|
677
|
+
const getSetSize = (items, index) => {
|
|
678
|
+
let setSize = 0;
|
|
679
|
+
for (let i = index + 1; i < items.length; i++) {
|
|
680
|
+
if (items[i].type === File$1) {
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
setSize++;
|
|
684
|
+
}
|
|
685
|
+
return setSize;
|
|
686
|
+
};
|
|
687
|
+
const getRemoveIndicesFile = (items, item, index, matchCount, fileCount) => {
|
|
688
|
+
const setSize = getSetSize(items, index);
|
|
689
|
+
return {
|
|
690
|
+
startIndex: index,
|
|
691
|
+
removeCount: setSize + 1,
|
|
692
|
+
newFocusedIndex: index + setSize + 1 < items.length ? index : index - 1,
|
|
693
|
+
newFileCount: fileCount - 1,
|
|
694
|
+
newMatchCount: matchCount - setSize
|
|
695
|
+
};
|
|
696
|
+
};
|
|
697
|
+
const getRemoveIndicesMatch = (items, index, matchCount, fileCount) => {
|
|
698
|
+
for (let i = index; i >= 0; i--) {
|
|
699
|
+
if (items[i].type === File$1) {
|
|
700
|
+
const setSize = getSetSize(items, i);
|
|
701
|
+
if (setSize === 1) {
|
|
702
|
+
return {
|
|
703
|
+
startIndex: i,
|
|
704
|
+
removeCount: 2,
|
|
705
|
+
newFocusedIndex: i - 1,
|
|
706
|
+
newFileCount: fileCount - 1,
|
|
707
|
+
newMatchCount: matchCount - 1
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
startIndex: index,
|
|
712
|
+
removeCount: 1,
|
|
713
|
+
newFocusedIndex: index,
|
|
714
|
+
newFileCount: fileCount,
|
|
715
|
+
newMatchCount: matchCount - 1
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
throw new Error('could not compute indices to remove');
|
|
720
|
+
};
|
|
721
|
+
const getRemoveIndices = (items, index, matchCount, fileCount) => {
|
|
722
|
+
const item = items[index];
|
|
723
|
+
switch (item.type) {
|
|
724
|
+
case File$1:
|
|
725
|
+
return getRemoveIndicesFile(items, item, index, matchCount, fileCount);
|
|
726
|
+
case Match:
|
|
727
|
+
return getRemoveIndicesMatch(items, index, matchCount, fileCount);
|
|
728
|
+
default:
|
|
729
|
+
throw new Error('unknown search result type');
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const removeItemFromItems = (items, index, matchCount, fileCount) => {
|
|
733
|
+
const {
|
|
734
|
+
startIndex,
|
|
735
|
+
removeCount,
|
|
736
|
+
newFocusedIndex,
|
|
737
|
+
newFileCount,
|
|
738
|
+
newMatchCount
|
|
739
|
+
} = getRemoveIndices(items, index, matchCount, fileCount);
|
|
740
|
+
const newItems = remove(items, startIndex, removeCount);
|
|
741
|
+
return {
|
|
742
|
+
newItems,
|
|
743
|
+
newFocusedIndex,
|
|
744
|
+
newFileCount,
|
|
745
|
+
newMatchCount
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
const getNewMinMax = (newItemsLength, minLineY, maxLineY, deltaY, itemHeight) => {
|
|
749
|
+
if (maxLineY > newItemsLength) {
|
|
750
|
+
const diff = maxLineY - minLineY;
|
|
751
|
+
const newMinLineY = Math.max(newItemsLength - diff, 0);
|
|
752
|
+
const newDeltaY = newMinLineY * itemHeight;
|
|
753
|
+
return {
|
|
754
|
+
newDeltaY,
|
|
755
|
+
newMinLineY,
|
|
756
|
+
newMaxLineY: newItemsLength
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
newDeltaY: deltaY,
|
|
761
|
+
newMinLineY: minLineY,
|
|
762
|
+
newMaxLineY: maxLineY
|
|
763
|
+
};
|
|
764
|
+
};
|
|
765
|
+
const dismissItem = state => {
|
|
766
|
+
const {
|
|
767
|
+
items,
|
|
768
|
+
listFocusedIndex,
|
|
769
|
+
fileCount,
|
|
770
|
+
matchCount,
|
|
771
|
+
minLineY,
|
|
772
|
+
maxLineY,
|
|
773
|
+
deltaY,
|
|
774
|
+
itemHeight
|
|
775
|
+
} = state;
|
|
776
|
+
if (listFocusedIndex === -1) {
|
|
777
|
+
return state;
|
|
778
|
+
}
|
|
779
|
+
const {
|
|
780
|
+
newItems,
|
|
781
|
+
newFocusedIndex,
|
|
782
|
+
newMatchCount,
|
|
783
|
+
newFileCount
|
|
784
|
+
} = removeItemFromItems(items, listFocusedIndex, matchCount, fileCount);
|
|
785
|
+
const message = getStatusMessage(newMatchCount, newFileCount);
|
|
786
|
+
const {
|
|
787
|
+
newMinLineY,
|
|
788
|
+
newMaxLineY,
|
|
789
|
+
newDeltaY
|
|
790
|
+
} = getNewMinMax(newItems.length, minLineY, maxLineY, deltaY, itemHeight);
|
|
791
|
+
return {
|
|
792
|
+
...state,
|
|
793
|
+
items: newItems,
|
|
794
|
+
listFocusedIndex: newFocusedIndex,
|
|
795
|
+
message,
|
|
796
|
+
matchCount: newMatchCount,
|
|
797
|
+
fileCount: newFileCount,
|
|
798
|
+
minLineY: newMinLineY,
|
|
799
|
+
maxLineY: newMaxLineY,
|
|
800
|
+
deltaY: newDeltaY
|
|
801
|
+
};
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
const focusMatchCase$1 = state => {
|
|
805
|
+
return {
|
|
806
|
+
...state,
|
|
807
|
+
focus: FocusSearchMatchCase
|
|
808
|
+
};
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
const focusReplaceValue$1 = state => {
|
|
812
|
+
return {
|
|
813
|
+
...state,
|
|
814
|
+
focus: FocusSearchReplaceInput
|
|
815
|
+
};
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
const focusSearchValue$1 = state => {
|
|
819
|
+
return {
|
|
820
|
+
...state,
|
|
821
|
+
focus: FocusSearchInput
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
const focusSearchValueNext$1 = state => {
|
|
826
|
+
const {
|
|
827
|
+
replaceExpanded
|
|
828
|
+
} = state;
|
|
829
|
+
if (replaceExpanded) {
|
|
830
|
+
return focusReplaceValue$1(state);
|
|
831
|
+
}
|
|
832
|
+
return focusMatchCase$1(state);
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
const CheckBox = 'checkbox';
|
|
836
|
+
const None = 'none';
|
|
837
|
+
const Status = 'status';
|
|
838
|
+
const Tree = 'tree';
|
|
839
|
+
const TreeItem$1 = 'treeitem';
|
|
840
|
+
const ToolBar = 'toolbar';
|
|
841
|
+
|
|
842
|
+
const Chevron = 'Chevron';
|
|
843
|
+
const CloseMaskIcon = 'MaskIcon MaskIconClose';
|
|
844
|
+
const Empty = '';
|
|
845
|
+
const FileIcon = 'FileIcon';
|
|
846
|
+
const IconButton = 'IconButton';
|
|
847
|
+
const Actions = 'Actions';
|
|
848
|
+
const FocusOutline = 'FocusOutline';
|
|
849
|
+
const Highlight = 'Highlight';
|
|
850
|
+
const HighlightDeleted = 'HighlightDeleted';
|
|
851
|
+
const HighlightInserted = 'HighlightInserted';
|
|
852
|
+
const Label = 'Label';
|
|
853
|
+
const List = 'List';
|
|
854
|
+
const MaskIcon = 'MaskIcon';
|
|
855
|
+
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
856
|
+
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
857
|
+
const MultilineInputBox = 'MultilineInputBox';
|
|
858
|
+
const Search$1 = 'Search';
|
|
859
|
+
const SearchField = 'SearchField';
|
|
860
|
+
const SearchFieldButtons = 'SearchFieldButtons';
|
|
861
|
+
const SearchFieldContainer = 'SearchFieldContainer';
|
|
862
|
+
const SearchHeader = 'SearchHeader';
|
|
863
|
+
const SearchHeaderTop = 'SearchHeaderTop';
|
|
864
|
+
const SearchRemove = 'SearchRemove';
|
|
865
|
+
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
866
|
+
const SourceControlBadge = 'SourceControlBadge';
|
|
867
|
+
const TreeItem = 'TreeItem';
|
|
868
|
+
const TreeItemActive = 'TreeItemActive';
|
|
869
|
+
const Viewlet = 'Viewlet';
|
|
870
|
+
const ViewletSearchMessage = 'ViewletSearchMessage';
|
|
871
|
+
|
|
872
|
+
const Button$1 = 1;
|
|
873
|
+
|
|
874
|
+
const Button = 1;
|
|
875
|
+
const Div = 4;
|
|
876
|
+
const Input = 6;
|
|
877
|
+
const Span = 8;
|
|
878
|
+
const Text = 12;
|
|
879
|
+
const Img = 17;
|
|
880
|
+
const Ins = 20;
|
|
881
|
+
const Del = 21;
|
|
882
|
+
const TextArea = 62;
|
|
883
|
+
|
|
884
|
+
const getIconVirtualDom = (icon, type = Div) => {
|
|
885
|
+
return {
|
|
886
|
+
type,
|
|
887
|
+
className: `MaskIcon MaskIcon${icon}`,
|
|
888
|
+
role: None,
|
|
889
|
+
childCount: 0
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const getActionButtonVirtualDom = action => {
|
|
894
|
+
const {
|
|
895
|
+
id,
|
|
896
|
+
icon,
|
|
897
|
+
command
|
|
898
|
+
} = action;
|
|
899
|
+
return [{
|
|
900
|
+
type: Button,
|
|
901
|
+
className: IconButton,
|
|
902
|
+
title: id,
|
|
903
|
+
'data-command': command,
|
|
904
|
+
childCount: 1
|
|
905
|
+
}, getIconVirtualDom(icon)];
|
|
343
906
|
};
|
|
344
|
-
|
|
345
|
-
|
|
907
|
+
|
|
908
|
+
const getActionVirtualDom = action => {
|
|
909
|
+
switch (action.type) {
|
|
910
|
+
case Button$1:
|
|
911
|
+
return getActionButtonVirtualDom(action);
|
|
912
|
+
default:
|
|
913
|
+
return [];
|
|
914
|
+
}
|
|
346
915
|
};
|
|
347
|
-
|
|
348
|
-
|
|
916
|
+
|
|
917
|
+
const getActionsVirtualDom = actions => {
|
|
918
|
+
return [{
|
|
919
|
+
type: Div,
|
|
920
|
+
className: Actions,
|
|
921
|
+
role: ToolBar,
|
|
922
|
+
childCount: actions.length
|
|
923
|
+
}, ...actions.flatMap(getActionVirtualDom)];
|
|
349
924
|
};
|
|
350
925
|
|
|
926
|
+
const ClearAll = 'ClearAll';
|
|
927
|
+
const CollapseAll = 'CollapseAll';
|
|
928
|
+
const ListFlat = 'ListFlat';
|
|
929
|
+
const NewFile = 'NewFile';
|
|
930
|
+
const Refresh = 'Refresh';
|
|
931
|
+
|
|
351
932
|
const getActions = () => {
|
|
352
933
|
return [{
|
|
353
934
|
type: Button$1,
|
|
354
|
-
id: refresh(),
|
|
935
|
+
id: refresh$1(),
|
|
355
936
|
icon: Refresh,
|
|
356
937
|
command: 'refresh'
|
|
357
938
|
}, {
|
|
@@ -381,9 +962,6 @@ const getFileIcon = () => {
|
|
|
381
962
|
return '';
|
|
382
963
|
};
|
|
383
964
|
|
|
384
|
-
const File$1 = 1;
|
|
385
|
-
const Match = 2;
|
|
386
|
-
|
|
387
965
|
// TODO this should be in FileSystem module
|
|
388
966
|
const pathBaseName = path => {
|
|
389
967
|
return path.slice(path.lastIndexOf('/') + 1);
|
|
@@ -742,505 +1320,484 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
742
1320
|
}
|
|
743
1321
|
dom.push(...getLabelVirtualDom(displayText, matchLength, matchStart, replacement));
|
|
744
1322
|
if (matchCount) {
|
|
745
|
-
treeItem.childCount++;
|
|
746
|
-
dom.push(...getBadgeVirtualDom(SourceControlBadge, matchCount));
|
|
747
|
-
}
|
|
748
|
-
treeItem.childCount++;
|
|
749
|
-
dom.push({
|
|
750
|
-
type: Div,
|
|
751
|
-
className: SearchRemove,
|
|
752
|
-
childCount: 1
|
|
753
|
-
}, {
|
|
754
|
-
type: Div,
|
|
755
|
-
className: CloseMaskIcon,
|
|
756
|
-
childCount: 0
|
|
757
|
-
});
|
|
758
|
-
return dom;
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
const getSearchResultsVirtualDom = visibleItems => {
|
|
762
|
-
return visibleItems.flatMap(getSearchResultVirtualDom);
|
|
763
|
-
};
|
|
764
|
-
|
|
765
|
-
const mergeClassNames = (...classNames) => {
|
|
766
|
-
return classNames.filter(Boolean).join(' ');
|
|
767
|
-
};
|
|
768
|
-
|
|
769
|
-
const getSearchVirtualDom = (visibleItems, replaceExpanded, matchCase, matchWholeWord, useRegularExpression, message, detailsExpanded, focusOutline) => {
|
|
770
|
-
/**
|
|
771
|
-
* @type {any[]}
|
|
772
|
-
*/
|
|
773
|
-
const dom = [];
|
|
774
|
-
dom.push({
|
|
775
|
-
type: Div,
|
|
776
|
-
className: mergeClassNames(Viewlet, Search$1),
|
|
777
|
-
childCount: 2
|
|
778
|
-
});
|
|
779
|
-
dom.push(...getSearchHeaderVirtualDom(replaceExpanded, matchCase, matchWholeWord, useRegularExpression, detailsExpanded));
|
|
780
|
-
dom.push({
|
|
781
|
-
type: Div,
|
|
782
|
-
className: ViewletSearchMessage,
|
|
783
|
-
role: Status,
|
|
784
|
-
tabIndex: 0,
|
|
785
|
-
childCount: 1
|
|
786
|
-
}, text(message));
|
|
787
|
-
dom.push({
|
|
788
|
-
type: Div,
|
|
789
|
-
className: mergeClassNames(Viewlet, List, focusOutline ? FocusOutline : Empty),
|
|
790
|
-
role: Tree,
|
|
791
|
-
tabIndex: 0,
|
|
792
|
-
childCount: visibleItems.length,
|
|
793
|
-
onClick: HandleClick,
|
|
794
|
-
onBlur: HandleListBlur
|
|
795
|
-
});
|
|
796
|
-
dom.push(...getSearchResultsVirtualDom(visibleItems));
|
|
797
|
-
return dom;
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
const handleIconThemeChange = state => {
|
|
801
|
-
const {
|
|
802
|
-
items
|
|
803
|
-
} = state;
|
|
804
|
-
const newItems = [...items];
|
|
805
|
-
return {
|
|
806
|
-
...state,
|
|
807
|
-
items: newItems
|
|
808
|
-
};
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
const handleError = async (error, notify = true, prefix = '') => {
|
|
812
|
-
console.error(`[text-search-worker] ${error}`);
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
// TODO optimize this function to return the minimum number
|
|
816
|
-
// of visible items needed, e.g. when not scrolled 5 items with
|
|
817
|
-
// 20px fill 100px but when scrolled 6 items are needed
|
|
818
|
-
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
819
|
-
return Math.ceil(listHeight / itemHeight) + 1;
|
|
820
|
-
};
|
|
821
|
-
|
|
822
|
-
const getTextSearchResultCounts = results => {
|
|
823
|
-
let resultCount = 0;
|
|
824
|
-
let fileCount = 0;
|
|
825
|
-
for (const result of results) {
|
|
826
|
-
switch (result.type) {
|
|
827
|
-
case File$1:
|
|
828
|
-
fileCount++;
|
|
829
|
-
break;
|
|
830
|
-
case Match:
|
|
831
|
-
resultCount++;
|
|
832
|
-
break;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
return {
|
|
836
|
-
fileCount,
|
|
837
|
-
resultCount
|
|
838
|
-
};
|
|
839
|
-
};
|
|
840
|
-
|
|
841
|
-
const EmptyString = '';
|
|
842
|
-
|
|
843
|
-
const isEmptyString = string => {
|
|
844
|
-
return string === EmptyString;
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
*
|
|
849
|
-
* @param {number} size
|
|
850
|
-
* @param {number} contentSize
|
|
851
|
-
* @param {number} minimumSliderSize
|
|
852
|
-
* @returns
|
|
853
|
-
*/
|
|
854
|
-
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
855
|
-
if (size >= contentSize) {
|
|
856
|
-
return 0;
|
|
857
|
-
}
|
|
858
|
-
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
const RE_PROTOCOL = /^([a-z\-]+):\/\//;
|
|
862
|
-
const getProtocol = uri => {
|
|
863
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
864
|
-
if (protocolMatch) {
|
|
865
|
-
return protocolMatch[1];
|
|
866
|
-
}
|
|
867
|
-
return '';
|
|
868
|
-
};
|
|
869
|
-
|
|
870
|
-
const state$3 = {
|
|
871
|
-
/**
|
|
872
|
-
* @type {any}
|
|
873
|
-
*/
|
|
874
|
-
ipc: undefined
|
|
875
|
-
};
|
|
876
|
-
const get$1 = () => {
|
|
877
|
-
return state$3.ipc;
|
|
878
|
-
};
|
|
879
|
-
const set$1 = ipc => {
|
|
880
|
-
state$3.ipc = ipc;
|
|
881
|
-
};
|
|
882
|
-
|
|
883
|
-
const Two = '2.0';
|
|
884
|
-
class AssertionError extends Error {
|
|
885
|
-
constructor(message) {
|
|
886
|
-
super(message);
|
|
887
|
-
this.name = 'AssertionError';
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
const getType = value => {
|
|
891
|
-
switch (typeof value) {
|
|
892
|
-
case 'number':
|
|
893
|
-
return 'number';
|
|
894
|
-
case 'function':
|
|
895
|
-
return 'function';
|
|
896
|
-
case 'string':
|
|
897
|
-
return 'string';
|
|
898
|
-
case 'object':
|
|
899
|
-
if (value === null) {
|
|
900
|
-
return 'null';
|
|
901
|
-
}
|
|
902
|
-
if (Array.isArray(value)) {
|
|
903
|
-
return 'array';
|
|
904
|
-
}
|
|
905
|
-
return 'object';
|
|
906
|
-
case 'boolean':
|
|
907
|
-
return 'boolean';
|
|
908
|
-
default:
|
|
909
|
-
return 'unknown';
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
const number = value => {
|
|
913
|
-
const type = getType(value);
|
|
914
|
-
if (type !== 'number') {
|
|
915
|
-
throw new AssertionError('expected value to be of type number');
|
|
1323
|
+
treeItem.childCount++;
|
|
1324
|
+
dom.push(...getBadgeVirtualDom(SourceControlBadge, matchCount));
|
|
916
1325
|
}
|
|
1326
|
+
treeItem.childCount++;
|
|
1327
|
+
dom.push({
|
|
1328
|
+
type: Div,
|
|
1329
|
+
className: SearchRemove,
|
|
1330
|
+
childCount: 1
|
|
1331
|
+
}, {
|
|
1332
|
+
type: Div,
|
|
1333
|
+
className: CloseMaskIcon,
|
|
1334
|
+
childCount: 0
|
|
1335
|
+
});
|
|
1336
|
+
return dom;
|
|
917
1337
|
};
|
|
918
|
-
|
|
919
|
-
|
|
1338
|
+
|
|
1339
|
+
const getSearchResultsVirtualDom = visibleItems => {
|
|
1340
|
+
return visibleItems.flatMap(getSearchResultVirtualDom);
|
|
920
1341
|
};
|
|
921
|
-
|
|
922
|
-
|
|
1342
|
+
|
|
1343
|
+
const mergeClassNames = (...classNames) => {
|
|
1344
|
+
return classNames.filter(Boolean).join(' ');
|
|
923
1345
|
};
|
|
924
|
-
|
|
925
|
-
|
|
1346
|
+
|
|
1347
|
+
const getSearchVirtualDom = (visibleItems, replaceExpanded, matchCase, matchWholeWord, useRegularExpression, message, detailsExpanded, focusOutline) => {
|
|
1348
|
+
/**
|
|
1349
|
+
* @type {any[]}
|
|
1350
|
+
*/
|
|
1351
|
+
const dom = [];
|
|
1352
|
+
dom.push({
|
|
1353
|
+
type: Div,
|
|
1354
|
+
className: mergeClassNames(Viewlet, Search$1),
|
|
1355
|
+
childCount: 2
|
|
1356
|
+
});
|
|
1357
|
+
dom.push(...getSearchHeaderVirtualDom(replaceExpanded, matchCase, matchWholeWord, useRegularExpression, detailsExpanded));
|
|
1358
|
+
dom.push({
|
|
1359
|
+
type: Div,
|
|
1360
|
+
className: ViewletSearchMessage,
|
|
1361
|
+
role: Status,
|
|
1362
|
+
tabIndex: 0,
|
|
1363
|
+
childCount: 1
|
|
1364
|
+
}, text(message));
|
|
1365
|
+
dom.push({
|
|
1366
|
+
type: Div,
|
|
1367
|
+
className: mergeClassNames(Viewlet, List, focusOutline ? FocusOutline : Empty),
|
|
1368
|
+
role: Tree,
|
|
1369
|
+
tabIndex: 0,
|
|
1370
|
+
childCount: visibleItems.length,
|
|
1371
|
+
onClick: HandleClick,
|
|
1372
|
+
onBlur: HandleListBlur
|
|
1373
|
+
});
|
|
1374
|
+
dom.push(...getSearchResultsVirtualDom(visibleItems));
|
|
1375
|
+
return dom;
|
|
926
1376
|
};
|
|
927
|
-
|
|
928
|
-
|
|
1377
|
+
|
|
1378
|
+
const handleIconThemeChange = state => {
|
|
1379
|
+
const {
|
|
1380
|
+
items
|
|
1381
|
+
} = state;
|
|
1382
|
+
const newItems = [...items];
|
|
1383
|
+
return {
|
|
1384
|
+
...state,
|
|
1385
|
+
items: newItems
|
|
1386
|
+
};
|
|
929
1387
|
};
|
|
930
|
-
|
|
931
|
-
|
|
1388
|
+
|
|
1389
|
+
const first = () => {
|
|
1390
|
+
return 0;
|
|
932
1391
|
};
|
|
933
|
-
const
|
|
934
|
-
return
|
|
1392
|
+
const last = items => {
|
|
1393
|
+
return items.length - 1;
|
|
935
1394
|
};
|
|
936
|
-
const
|
|
937
|
-
|
|
1395
|
+
const next = (items, index) => {
|
|
1396
|
+
return (index + 1) % items.length;
|
|
938
1397
|
};
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
const {
|
|
942
|
-
resolve,
|
|
943
|
-
promise
|
|
944
|
-
} = Promise.withResolvers();
|
|
945
|
-
set(id, resolve);
|
|
946
|
-
return {
|
|
947
|
-
id,
|
|
948
|
-
promise
|
|
949
|
-
};
|
|
1398
|
+
const previous = (items, index) => {
|
|
1399
|
+
return index === 0 ? items.length - 1 : index - 1;
|
|
950
1400
|
};
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
fn(args);
|
|
960
|
-
remove(id);
|
|
1401
|
+
|
|
1402
|
+
// TODO optimize this function to return the minimum number
|
|
1403
|
+
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1404
|
+
// 20px fill 100px but when scrolled 6 items are needed
|
|
1405
|
+
const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
1406
|
+
return Math.ceil(listHeight / itemHeight) + 1;
|
|
961
1407
|
};
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1408
|
+
|
|
1409
|
+
const focusIndexScrollUp = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1410
|
+
const newMinLineY = index;
|
|
1411
|
+
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1412
|
+
const newMaxLineY = Math.min(newMinLineY + fittingItems, itemsLength);
|
|
1413
|
+
const newDeltaY = newMinLineY * itemHeight;
|
|
1414
|
+
return {
|
|
1415
|
+
...state,
|
|
1416
|
+
focusedIndex: index,
|
|
1417
|
+
minLineY: newMinLineY,
|
|
1418
|
+
maxLineY: newMaxLineY,
|
|
1419
|
+
focused: true,
|
|
1420
|
+
deltaY: newDeltaY
|
|
972
1421
|
};
|
|
1422
|
+
};
|
|
1423
|
+
const focusIndexScrollDown = (state, index, listHeight, itemHeight, itemsLength) => {
|
|
1424
|
+
const newMaxLineY = Math.min(index + 1, itemsLength);
|
|
1425
|
+
const fittingItems = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1426
|
+
const newMinLineY = Math.max(newMaxLineY - fittingItems, 0);
|
|
1427
|
+
const newDeltaY = itemsLength < fittingItems ? 0 : newMinLineY * itemHeight - listHeight % itemHeight + itemHeight;
|
|
973
1428
|
return {
|
|
974
|
-
|
|
975
|
-
|
|
1429
|
+
...state,
|
|
1430
|
+
focusedIndex: index,
|
|
1431
|
+
minLineY: newMinLineY,
|
|
1432
|
+
maxLineY: newMaxLineY,
|
|
1433
|
+
focused: true,
|
|
1434
|
+
deltaY: newDeltaY
|
|
976
1435
|
};
|
|
977
1436
|
};
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
if (type) {
|
|
991
|
-
switch (type) {
|
|
992
|
-
case DomException:
|
|
993
|
-
return DOMException;
|
|
994
|
-
case TypeError$1:
|
|
995
|
-
return TypeError;
|
|
996
|
-
case SyntaxError$1:
|
|
997
|
-
return SyntaxError;
|
|
998
|
-
case ReferenceError$1:
|
|
999
|
-
return ReferenceError;
|
|
1000
|
-
default:
|
|
1001
|
-
return Error;
|
|
1002
|
-
}
|
|
1437
|
+
const focusIndex = (state, index) => {
|
|
1438
|
+
const {
|
|
1439
|
+
itemHeight,
|
|
1440
|
+
minLineY,
|
|
1441
|
+
maxLineY,
|
|
1442
|
+
headerHeight,
|
|
1443
|
+
height,
|
|
1444
|
+
items
|
|
1445
|
+
} = state;
|
|
1446
|
+
const itemsLength = items.length;
|
|
1447
|
+
if (itemsLength === 0) {
|
|
1448
|
+
return state;
|
|
1003
1449
|
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1450
|
+
number(itemHeight);
|
|
1451
|
+
if (index === -1) {
|
|
1452
|
+
return {
|
|
1453
|
+
...state,
|
|
1454
|
+
focusedIndex: -1,
|
|
1455
|
+
focused: true
|
|
1456
|
+
};
|
|
1006
1457
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1458
|
+
const listHeight = height - headerHeight;
|
|
1459
|
+
if (index < minLineY + 1) {
|
|
1460
|
+
return focusIndexScrollUp(state, index, listHeight, itemHeight, itemsLength);
|
|
1009
1461
|
}
|
|
1010
|
-
if (
|
|
1011
|
-
return
|
|
1462
|
+
if (index >= maxLineY - 1) {
|
|
1463
|
+
return focusIndexScrollDown(state, index, listHeight, itemHeight, itemsLength);
|
|
1012
1464
|
}
|
|
1013
|
-
return
|
|
1465
|
+
return {
|
|
1466
|
+
...state,
|
|
1467
|
+
focusedIndex: index,
|
|
1468
|
+
focused: true
|
|
1469
|
+
};
|
|
1014
1470
|
};
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1471
|
+
|
|
1472
|
+
const focusFirst = state => {
|
|
1473
|
+
const firstIndex = first();
|
|
1474
|
+
return focusIndex(state, firstIndex);
|
|
1475
|
+
};
|
|
1476
|
+
|
|
1477
|
+
const focusLast = state => {
|
|
1478
|
+
const {
|
|
1479
|
+
items
|
|
1480
|
+
} = state;
|
|
1481
|
+
const lastIndex = last(items);
|
|
1482
|
+
return focusIndex(state, lastIndex);
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
const focusNext = state => {
|
|
1486
|
+
const {
|
|
1487
|
+
focusedIndex,
|
|
1488
|
+
items
|
|
1489
|
+
} = state;
|
|
1490
|
+
const nextIndex = next(items, focusedIndex);
|
|
1491
|
+
return focusIndex(state, nextIndex);
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1494
|
+
const focusNextPage = state => {
|
|
1495
|
+
const {
|
|
1496
|
+
focusedIndex,
|
|
1497
|
+
items,
|
|
1498
|
+
maxLineY,
|
|
1499
|
+
minLineY
|
|
1500
|
+
} = state;
|
|
1501
|
+
if (isLastIndex(items, focusedIndex)) {
|
|
1502
|
+
return state;
|
|
1026
1503
|
}
|
|
1027
|
-
|
|
1504
|
+
const indexNextPage = Math.min(maxLineY + (maxLineY - minLineY) - 2, lastIndex(items));
|
|
1505
|
+
return focusIndex(state, indexNextPage);
|
|
1028
1506
|
};
|
|
1029
|
-
|
|
1030
|
-
|
|
1507
|
+
|
|
1508
|
+
const focusPreviousPage = state => {
|
|
1509
|
+
const {
|
|
1510
|
+
focusedIndex,
|
|
1511
|
+
minLineY,
|
|
1512
|
+
maxLineY
|
|
1513
|
+
} = state;
|
|
1514
|
+
if (focusedIndex === 0 || focusedIndex === -1) {
|
|
1515
|
+
return state;
|
|
1516
|
+
}
|
|
1517
|
+
const indexPreviousPage = Math.max(minLineY - (maxLineY - minLineY) + 1, 0);
|
|
1518
|
+
return focusIndex(state, indexPreviousPage);
|
|
1031
1519
|
};
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1520
|
+
|
|
1521
|
+
const focusPrevious = state => {
|
|
1522
|
+
const {
|
|
1523
|
+
focusedIndex,
|
|
1524
|
+
items
|
|
1525
|
+
} = state;
|
|
1526
|
+
if (focusedIndex === 0 || focusedIndex === -1) {
|
|
1527
|
+
return state;
|
|
1036
1528
|
}
|
|
1037
|
-
|
|
1529
|
+
const previousIndex = previous(items, focusedIndex);
|
|
1530
|
+
return focusIndex(state, previousIndex);
|
|
1038
1531
|
};
|
|
1039
|
-
|
|
1040
|
-
|
|
1532
|
+
|
|
1533
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
1534
|
+
const relativeY = eventY - y + deltaY;
|
|
1535
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
1536
|
+
return index;
|
|
1041
1537
|
};
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1045
|
-
return lines.split(NewLine$3);
|
|
1538
|
+
|
|
1539
|
+
const openUri = async (path, focus = true, props = {}) => {
|
|
1540
|
+
await invoke$1(/* Main.openUri */'Main.openUri', /* uri */path, /* focus */focus, props);
|
|
1046
1541
|
};
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
const restoredError = new JsonRpcError(error.message);
|
|
1054
|
-
const parentStack = getParentStack(error);
|
|
1055
|
-
restoredError.stack = parentStack + NewLine$3 + currentStack;
|
|
1056
|
-
return restoredError;
|
|
1057
|
-
}
|
|
1058
|
-
if (error && error.message) {
|
|
1059
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
1060
|
-
if (error.data) {
|
|
1061
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
1062
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$3 + error.data.stack + NewLine$3 + currentStack;
|
|
1063
|
-
} else if (error.data.stack) {
|
|
1064
|
-
restoredError.stack = error.data.stack;
|
|
1065
|
-
}
|
|
1066
|
-
if (error.data.codeFrame) {
|
|
1067
|
-
// @ts-ignore
|
|
1068
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
1069
|
-
}
|
|
1070
|
-
if (error.data.code) {
|
|
1071
|
-
// @ts-ignore
|
|
1072
|
-
restoredError.code = error.data.code;
|
|
1073
|
-
}
|
|
1074
|
-
if (error.data.type) {
|
|
1075
|
-
// @ts-ignore
|
|
1076
|
-
restoredError.name = error.data.type;
|
|
1077
|
-
}
|
|
1078
|
-
} else {
|
|
1079
|
-
if (error.stack) {
|
|
1080
|
-
const lowerStack = restoredError.stack || '';
|
|
1081
|
-
// @ts-ignore
|
|
1082
|
-
const indexNewLine = getNewLineIndex$2(lowerStack);
|
|
1083
|
-
const parentStack = getParentStack(error);
|
|
1084
|
-
// @ts-ignore
|
|
1085
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1086
|
-
}
|
|
1087
|
-
if (error.codeFrame) {
|
|
1088
|
-
// @ts-ignore
|
|
1089
|
-
restoredError.codeFrame = error.codeFrame;
|
|
1090
|
-
}
|
|
1542
|
+
|
|
1543
|
+
const getFileIndex = (items, index) => {
|
|
1544
|
+
for (let i = index; i >= 0; i--) {
|
|
1545
|
+
const item = items[i];
|
|
1546
|
+
if (item.type === File$1) {
|
|
1547
|
+
return i;
|
|
1091
1548
|
}
|
|
1092
|
-
return restoredError;
|
|
1093
1549
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1550
|
+
return -1;
|
|
1551
|
+
};
|
|
1552
|
+
const selectIndexFile = async (state, searchResult, index) => {
|
|
1553
|
+
const {
|
|
1554
|
+
collapsedPaths
|
|
1555
|
+
} = state;
|
|
1556
|
+
const path = getAbsolutePath(searchResult.text);
|
|
1557
|
+
string(path);
|
|
1558
|
+
return {
|
|
1559
|
+
...state,
|
|
1560
|
+
collapsedPaths: [...collapsedPaths, path],
|
|
1561
|
+
listFocusedIndex: index,
|
|
1562
|
+
listFocused: true
|
|
1563
|
+
};
|
|
1564
|
+
};
|
|
1565
|
+
const selectIndexPreview = async (state, searchResult, index) => {
|
|
1566
|
+
const {
|
|
1567
|
+
items
|
|
1568
|
+
} = state;
|
|
1569
|
+
const fileIndex = getFileIndex(items, index);
|
|
1570
|
+
if (fileIndex === -1) {
|
|
1571
|
+
throw new Error('Search result is missing file');
|
|
1096
1572
|
}
|
|
1097
|
-
|
|
1573
|
+
const {
|
|
1574
|
+
lineNumber
|
|
1575
|
+
} = searchResult;
|
|
1576
|
+
// console.log({ searchResult })
|
|
1577
|
+
const fileResult = items[fileIndex];
|
|
1578
|
+
const path = getAbsolutePath(fileResult.text);
|
|
1579
|
+
string(path);
|
|
1580
|
+
await openUri(path, true, {
|
|
1581
|
+
selections: new Uint32Array([lineNumber, 0, lineNumber, 0])
|
|
1582
|
+
});
|
|
1583
|
+
return {
|
|
1584
|
+
...state,
|
|
1585
|
+
listFocusedIndex: index,
|
|
1586
|
+
listFocused: false
|
|
1587
|
+
};
|
|
1098
1588
|
};
|
|
1099
|
-
const
|
|
1100
|
-
if (
|
|
1101
|
-
|
|
1102
|
-
|
|
1589
|
+
const selectIndex = async (state, index, isClose) => {
|
|
1590
|
+
if (index === -1) {
|
|
1591
|
+
return {
|
|
1592
|
+
...state,
|
|
1593
|
+
listFocused: true,
|
|
1594
|
+
listFocusedIndex: -1
|
|
1595
|
+
};
|
|
1103
1596
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1597
|
+
const {
|
|
1598
|
+
items
|
|
1599
|
+
} = state;
|
|
1600
|
+
const searchResult = items[index];
|
|
1601
|
+
switch (searchResult.type) {
|
|
1602
|
+
case File$1:
|
|
1603
|
+
return selectIndexFile(state, searchResult, index);
|
|
1604
|
+
case Match:
|
|
1605
|
+
return selectIndexPreview(state, searchResult, index);
|
|
1606
|
+
default:
|
|
1607
|
+
throw new Error(`unexpected search result type ${searchResult.type}`);
|
|
1106
1608
|
}
|
|
1107
|
-
throw new JsonRpcError('unexpected response message');
|
|
1108
1609
|
};
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1610
|
+
|
|
1611
|
+
const handleClickAt = async (state, eventX, eventY) => {
|
|
1612
|
+
const {
|
|
1613
|
+
x,
|
|
1614
|
+
y,
|
|
1615
|
+
itemHeight,
|
|
1616
|
+
deltaY
|
|
1617
|
+
} = state;
|
|
1618
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight);
|
|
1619
|
+
return selectIndex(state, index);
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
const handleScrollBarCaptureLost = state => {
|
|
1623
|
+
return {
|
|
1624
|
+
...state,
|
|
1625
|
+
scrollBarActive: false
|
|
1626
|
+
};
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
/**
|
|
1630
|
+
*
|
|
1631
|
+
* @param {number} size
|
|
1632
|
+
* @param {number} contentSize
|
|
1633
|
+
* @param {number} minimumSliderSize
|
|
1634
|
+
* @returns
|
|
1635
|
+
*/
|
|
1636
|
+
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1637
|
+
if (size >= contentSize) {
|
|
1638
|
+
return 0;
|
|
1116
1639
|
}
|
|
1117
|
-
return
|
|
1640
|
+
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
1118
1641
|
};
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1642
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
1643
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
1644
|
+
return scrollBarOffset;
|
|
1645
|
+
};
|
|
1646
|
+
const getScrollBarY = getScrollBarOffset;
|
|
1647
|
+
const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
1648
|
+
const halfScrollBarHeight = scrollBarHeight / 2;
|
|
1649
|
+
if (relativeY <= halfScrollBarHeight) {
|
|
1650
|
+
// clicked at top
|
|
1121
1651
|
return {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1652
|
+
percent: 0,
|
|
1653
|
+
handleOffset: relativeY
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
if (relativeY <= height - halfScrollBarHeight) {
|
|
1657
|
+
// clicked in middle
|
|
1658
|
+
return {
|
|
1659
|
+
percent: (relativeY - halfScrollBarHeight) / (height - scrollBarHeight),
|
|
1660
|
+
handleOffset: halfScrollBarHeight
|
|
1125
1661
|
};
|
|
1126
1662
|
}
|
|
1663
|
+
// clicked at bottom
|
|
1127
1664
|
return {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
data: {
|
|
1131
|
-
stack: prettyError.stack,
|
|
1132
|
-
codeFrame: prettyError.codeFrame,
|
|
1133
|
-
type: getErrorType(prettyError),
|
|
1134
|
-
code: prettyError.code,
|
|
1135
|
-
name: prettyError.name
|
|
1136
|
-
}
|
|
1665
|
+
percent: 1,
|
|
1666
|
+
handleOffset: scrollBarHeight - height + relativeY
|
|
1137
1667
|
};
|
|
1138
1668
|
};
|
|
1139
|
-
|
|
1669
|
+
|
|
1670
|
+
const clamp = (num, min, max) => {
|
|
1671
|
+
number(num);
|
|
1672
|
+
number(min);
|
|
1673
|
+
number(max);
|
|
1674
|
+
return Math.min(Math.max(num, min), max);
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
const setDeltaY = (state, value) => {
|
|
1678
|
+
object(state);
|
|
1679
|
+
number(value);
|
|
1680
|
+
const {
|
|
1681
|
+
itemHeight,
|
|
1682
|
+
finalDeltaY,
|
|
1683
|
+
deltaY,
|
|
1684
|
+
height,
|
|
1685
|
+
headerHeight
|
|
1686
|
+
} = state;
|
|
1687
|
+
const listHeight = height - headerHeight;
|
|
1688
|
+
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
1689
|
+
if (deltaY === newDeltaY) {
|
|
1690
|
+
return state;
|
|
1691
|
+
}
|
|
1692
|
+
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
1693
|
+
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
1694
|
+
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1140
1695
|
return {
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1696
|
+
...state,
|
|
1697
|
+
deltaY: newDeltaY,
|
|
1698
|
+
minLineY,
|
|
1699
|
+
maxLineY
|
|
1144
1700
|
};
|
|
1145
1701
|
};
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1702
|
+
|
|
1703
|
+
const handleScrollBarClick = (state, eventY) => {
|
|
1704
|
+
const {
|
|
1705
|
+
y,
|
|
1706
|
+
deltaY,
|
|
1707
|
+
headerHeight,
|
|
1708
|
+
finalDeltaY,
|
|
1709
|
+
scrollBarHeight,
|
|
1710
|
+
height
|
|
1711
|
+
} = state;
|
|
1712
|
+
const contentHeight = height - headerHeight;
|
|
1713
|
+
const relativeY = eventY - y - headerHeight;
|
|
1714
|
+
const currentScrollBarY = getScrollBarY(deltaY, finalDeltaY, contentHeight, scrollBarHeight);
|
|
1715
|
+
const diff = relativeY - currentScrollBarY;
|
|
1716
|
+
if (diff >= 0 && diff < scrollBarHeight) {
|
|
1717
|
+
return {
|
|
1718
|
+
...state,
|
|
1719
|
+
handleOffset: diff,
|
|
1720
|
+
scrollBarActive: true
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
const {
|
|
1724
|
+
percent,
|
|
1725
|
+
handleOffset
|
|
1726
|
+
} = getNewDeltaPercent(contentHeight, scrollBarHeight, relativeY);
|
|
1727
|
+
const newDeltaY = percent * finalDeltaY;
|
|
1153
1728
|
return {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1729
|
+
...setDeltaY(state, newDeltaY),
|
|
1730
|
+
handleOffset,
|
|
1731
|
+
scrollBarActive: true
|
|
1157
1732
|
};
|
|
1158
1733
|
};
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
try {
|
|
1165
|
-
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
1166
|
-
return getSuccessResponse(message, result);
|
|
1167
|
-
} catch (error) {
|
|
1168
|
-
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
1734
|
+
|
|
1735
|
+
const getNewPercent = (contentHeight, scrollBarHeight, relativeY) => {
|
|
1736
|
+
if (relativeY <= contentHeight - scrollBarHeight / 2) {
|
|
1737
|
+
// clicked in middle
|
|
1738
|
+
return relativeY / (contentHeight - scrollBarHeight);
|
|
1169
1739
|
}
|
|
1740
|
+
// clicked at bottom
|
|
1741
|
+
return 1;
|
|
1170
1742
|
};
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1743
|
+
const handleScrollBarMove = (state, eventY) => {
|
|
1744
|
+
const {
|
|
1745
|
+
y,
|
|
1746
|
+
headerHeight,
|
|
1747
|
+
handleOffset,
|
|
1748
|
+
finalDeltaY,
|
|
1749
|
+
height,
|
|
1750
|
+
scrollBarHeight
|
|
1751
|
+
} = state;
|
|
1752
|
+
const relativeY = eventY - y - headerHeight - handleOffset;
|
|
1753
|
+
const contentHeight = height - headerHeight;
|
|
1754
|
+
const newPercent = getNewPercent(contentHeight, scrollBarHeight, relativeY);
|
|
1755
|
+
const newDeltaY = newPercent * finalDeltaY;
|
|
1756
|
+
return setDeltaY(state, newDeltaY);
|
|
1173
1757
|
};
|
|
1174
|
-
|
|
1175
|
-
|
|
1758
|
+
|
|
1759
|
+
const handleWheel = (state, deltaMode, deltaY) => {
|
|
1760
|
+
number(deltaMode);
|
|
1761
|
+
number(deltaY);
|
|
1762
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
1176
1763
|
};
|
|
1177
|
-
|
|
1178
|
-
|
|
1764
|
+
|
|
1765
|
+
const handleError = async (error, notify = true, prefix = '') => {
|
|
1766
|
+
console.error(`[text-search-worker] ${error}`);
|
|
1179
1767
|
};
|
|
1180
|
-
|
|
1181
|
-
const
|
|
1182
|
-
let
|
|
1183
|
-
let
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
ipc = arg.ipc;
|
|
1193
|
-
execute = arg.execute;
|
|
1194
|
-
preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
|
|
1195
|
-
logError = arg.logError || defaultLogError;
|
|
1196
|
-
requiresSocket = arg.requiresSocket || defaultRequiresSocket;
|
|
1197
|
-
resolve = arg.resolve || defaultResolve;
|
|
1198
|
-
} else {
|
|
1199
|
-
ipc = args[0];
|
|
1200
|
-
message = args[1];
|
|
1201
|
-
execute = args[2];
|
|
1202
|
-
resolve = args[3];
|
|
1203
|
-
preparePrettyError = args[4];
|
|
1204
|
-
logError = args[5];
|
|
1205
|
-
requiresSocket = args[6];
|
|
1206
|
-
}
|
|
1207
|
-
if ('id' in message) {
|
|
1208
|
-
if ('method' in message) {
|
|
1209
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1210
|
-
try {
|
|
1211
|
-
ipc.send(response);
|
|
1212
|
-
} catch (error) {
|
|
1213
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
1214
|
-
ipc.send(errorResponse);
|
|
1215
|
-
}
|
|
1216
|
-
return;
|
|
1768
|
+
|
|
1769
|
+
const getTextSearchResultCounts = results => {
|
|
1770
|
+
let resultCount = 0;
|
|
1771
|
+
let fileCount = 0;
|
|
1772
|
+
for (const result of results) {
|
|
1773
|
+
switch (result.type) {
|
|
1774
|
+
case File$1:
|
|
1775
|
+
fileCount++;
|
|
1776
|
+
break;
|
|
1777
|
+
case Match:
|
|
1778
|
+
resultCount++;
|
|
1779
|
+
break;
|
|
1217
1780
|
}
|
|
1218
|
-
resolve(message.id, message);
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
if ('method' in message) {
|
|
1222
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1223
|
-
return;
|
|
1224
1781
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
message,
|
|
1230
|
-
promise
|
|
1231
|
-
} = create$2(method, params);
|
|
1232
|
-
ipc.send(message);
|
|
1233
|
-
const responseMessage = await promise;
|
|
1234
|
-
const result = unwrapJsonRpcResult(responseMessage);
|
|
1235
|
-
return result;
|
|
1782
|
+
return {
|
|
1783
|
+
fileCount,
|
|
1784
|
+
resultCount
|
|
1785
|
+
};
|
|
1236
1786
|
};
|
|
1237
1787
|
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1240
|
-
|
|
1788
|
+
const EmptyString = '';
|
|
1789
|
+
|
|
1790
|
+
const isEmptyString = string => {
|
|
1791
|
+
return string === EmptyString;
|
|
1241
1792
|
};
|
|
1242
|
-
|
|
1243
|
-
|
|
1793
|
+
|
|
1794
|
+
const RE_PROTOCOL = /^([a-z\-]+):\/\//;
|
|
1795
|
+
const getProtocol = uri => {
|
|
1796
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1797
|
+
if (protocolMatch) {
|
|
1798
|
+
return protocolMatch[1];
|
|
1799
|
+
}
|
|
1800
|
+
return '';
|
|
1244
1801
|
};
|
|
1245
1802
|
|
|
1246
1803
|
const textSearch$5 = async (scheme, root, query) => {
|
|
@@ -1696,24 +2253,6 @@ const getDirectoryHandle = async uri => {
|
|
|
1696
2253
|
return getDirectoryHandle(dirname$1);
|
|
1697
2254
|
};
|
|
1698
2255
|
|
|
1699
|
-
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
1700
|
-
|
|
1701
|
-
const insertInto = (array, start, newItems) => {
|
|
1702
|
-
const originalLength = array.length;
|
|
1703
|
-
const newItemsLength = newItems.length;
|
|
1704
|
-
array.length = originalLength + newItemsLength;
|
|
1705
|
-
// Move the items after the start index, start from the end so that we don't overwrite any value.
|
|
1706
|
-
for (let i = originalLength - 1; i >= start; i--) {
|
|
1707
|
-
array[i + newItemsLength] = array[i];
|
|
1708
|
-
}
|
|
1709
|
-
for (let i = 0; i < newItemsLength; i++) {
|
|
1710
|
-
array[i + start] = newItems[i];
|
|
1711
|
-
}
|
|
1712
|
-
};
|
|
1713
|
-
const push = (array, newItems) => {
|
|
1714
|
-
insertInto(array, array.length, newItems);
|
|
1715
|
-
};
|
|
1716
|
-
|
|
1717
2256
|
const NotReadableError = 'NotReadableError';
|
|
1718
2257
|
|
|
1719
2258
|
const isNotReadableError = error => {
|
|
@@ -1881,21 +2420,6 @@ const textSearch = async (root, query, options, assetDir) => {
|
|
|
1881
2420
|
return results;
|
|
1882
2421
|
};
|
|
1883
2422
|
|
|
1884
|
-
const getStatusMessage = (resultCount, fileResultCount) => {
|
|
1885
|
-
number$1(resultCount);
|
|
1886
|
-
number$1(fileResultCount);
|
|
1887
|
-
if (resultCount === 0) {
|
|
1888
|
-
return noResults();
|
|
1889
|
-
}
|
|
1890
|
-
if (resultCount === 1) {
|
|
1891
|
-
return oneResult();
|
|
1892
|
-
}
|
|
1893
|
-
if (fileResultCount === 1) {
|
|
1894
|
-
return manyResultsInOneFile(resultCount);
|
|
1895
|
-
}
|
|
1896
|
-
return manyResultsInManyFiles(resultCount, fileResultCount);
|
|
1897
|
-
};
|
|
1898
|
-
|
|
1899
2423
|
const handleUpdate = async (state, update) => {
|
|
1900
2424
|
const partialNewState = {
|
|
1901
2425
|
...state,
|
|
@@ -1997,7 +2521,7 @@ const getThreads = () => {
|
|
|
1997
2521
|
return 1;
|
|
1998
2522
|
};
|
|
1999
2523
|
const loadContent = async (uid, savedState) => {
|
|
2000
|
-
const state = get
|
|
2524
|
+
const state = get(uid);
|
|
2001
2525
|
const savedValue = getSavedValue(savedState);
|
|
2002
2526
|
const savedReplaceExpanded = getSavedReplaceExpanded(savedState);
|
|
2003
2527
|
const savedCollapsedPaths = getSavedCollapsedPaths(savedState);
|
|
@@ -2019,6 +2543,10 @@ const loadContent = async (uid, savedState) => {
|
|
|
2019
2543
|
};
|
|
2020
2544
|
};
|
|
2021
2545
|
|
|
2546
|
+
const refresh = state => {
|
|
2547
|
+
return handleUpdate(state, {});
|
|
2548
|
+
};
|
|
2549
|
+
|
|
2022
2550
|
const renderItems = {
|
|
2023
2551
|
isEqual(oldState, newState) {
|
|
2024
2552
|
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.replaceExpanded === newState.replaceExpanded && oldState.matchCase === newState.matchCase && oldState.matchWholeWord === newState.matchWholeWord && oldState.useRegularExpression === newState.useRegularExpression && oldState.message === newState.message && oldState.detailsExpanded === newState.detailsExpanded && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused;
|
|
@@ -2050,7 +2578,7 @@ const renderFocus = {
|
|
|
2050
2578
|
isEqual(oldState, newState) {
|
|
2051
2579
|
return oldState.focus === newState.focus;
|
|
2052
2580
|
},
|
|
2053
|
-
apply(
|
|
2581
|
+
apply(newState) {
|
|
2054
2582
|
const selector = getSelector(newState.focus);
|
|
2055
2583
|
return ['setFocus', selector];
|
|
2056
2584
|
}
|
|
@@ -2144,9 +2672,9 @@ const Keyboard = -1;
|
|
|
2144
2672
|
|
|
2145
2673
|
const show = async (x, y, id, ...args) => {
|
|
2146
2674
|
// TODO ask renderer worker to show context menu
|
|
2147
|
-
number
|
|
2148
|
-
number
|
|
2149
|
-
number
|
|
2675
|
+
number(x);
|
|
2676
|
+
number(y);
|
|
2677
|
+
number(id);
|
|
2150
2678
|
// TODO
|
|
2151
2679
|
};
|
|
2152
2680
|
|
|
@@ -2178,12 +2706,22 @@ const commandMap = {
|
|
|
2178
2706
|
'SearchView.focusReplaceValue': focusReplaceValue$1,
|
|
2179
2707
|
'SearchView.focusSearchValue': focusSearchValue$1,
|
|
2180
2708
|
'SearchView.focusSearchValueNext': focusSearchValueNext$1,
|
|
2181
|
-
'TextSearch.
|
|
2709
|
+
'TextSearch.clearSearchResults': clearSearchResults$1,
|
|
2710
|
+
'TextSearch.copy': copy,
|
|
2711
|
+
'TextSearch.create': create,
|
|
2712
|
+
'TextSearch.dismissItem': dismissItem,
|
|
2182
2713
|
'TextSearch.doRender': doRender,
|
|
2714
|
+
'TextSearch.focusFirst': focusFirst,
|
|
2715
|
+
'TextSearch.focusIndex': focusIndex,
|
|
2716
|
+
'TextSearch.focusLast': focusLast,
|
|
2183
2717
|
'TextSearch.focusMatchCase': focusMatchCase,
|
|
2184
2718
|
'TextSearch.focusMatchCasePrevious': focusMatchCasePrevious,
|
|
2185
2719
|
'TextSearch.focusMatchWholeWord': focusMatchWholeWord,
|
|
2720
|
+
'TextSearch.focusNext': focusNext,
|
|
2721
|
+
'TextSearch.focusNextPage': focusNextPage,
|
|
2186
2722
|
'TextSearch.focusPreserveCase': focusPreserveCase,
|
|
2723
|
+
'TextSearch.focusPrevious': focusPrevious,
|
|
2724
|
+
'TextSearch.focusPreviousPage': focusPreviousPage,
|
|
2187
2725
|
'TextSearch.focusRegex': focusRegex,
|
|
2188
2726
|
'TextSearch.focusRegexNext': focusRegexNext,
|
|
2189
2727
|
'TextSearch.focusReplaceAll': focusReplaceAll,
|
|
@@ -2195,9 +2733,15 @@ const commandMap = {
|
|
|
2195
2733
|
'TextSearch.getActionsVirtualDom': getActionsVirtualDom,
|
|
2196
2734
|
'TextSearch.getSearchDisplayResults': getDisplayResults,
|
|
2197
2735
|
'TextSearch.getVirtualDom': getSearchVirtualDom,
|
|
2736
|
+
'TextSearch.handleClickAt': handleClickAt,
|
|
2198
2737
|
'TextSearch.handleContextMenu': handleContextMenu,
|
|
2199
2738
|
'TextSearch.handleIconThemeChange': handleIconThemeChange,
|
|
2739
|
+
'TextSearch.handleScrollBarCaptureLost': handleScrollBarCaptureLost,
|
|
2740
|
+
'TextSearch.handleScrollBarClick': handleScrollBarClick,
|
|
2741
|
+
'TextSearch.handleScrollBarMove': handleScrollBarMove,
|
|
2742
|
+
'TextSearch.handleWheel': handleWheel,
|
|
2200
2743
|
'TextSearch.loadContent': loadContent,
|
|
2744
|
+
'TextSearch.refresh': refresh,
|
|
2201
2745
|
'TextSearch.submit': submit,
|
|
2202
2746
|
'TextSearch.textSearch': textSearch
|
|
2203
2747
|
};
|