@lvce-editor/file-search-worker 6.10.0 → 6.12.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.
@@ -1086,7 +1086,7 @@ const sendMessagePortToEditorWorker = async (port, rpcId) => {
1086
1086
  // @ts-ignore
1087
1087
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1088
1088
  };
1089
- const setFocus$1 = key => {
1089
+ const setFocus = key => {
1090
1090
  return invoke$1('Focus.setFocus', key);
1091
1091
  };
1092
1092
  const getFileIcon = async options => {
@@ -1380,20 +1380,23 @@ const setColorTheme = id => {
1380
1380
  };
1381
1381
 
1382
1382
  const focusPick$1 = async pick => {
1383
- const label = pick.label;
1384
- await setColorTheme(/* colorThemeId */label);
1383
+ const {
1384
+ label
1385
+ } = pick;
1386
+ await setColorTheme(label);
1385
1387
  };
1386
1388
 
1387
1389
  const ColorTheme$1 = 0;
1388
1390
  const Commands$1 = 1;
1389
1391
  const Custom$1 = 2;
1390
1392
  const File$2 = 3;
1391
- const GoToLine$2 = 4;
1392
- const Help$2 = 5;
1393
- const Recent$1 = 6;
1394
- const Symbol$2 = 7;
1395
- const View$3 = 8;
1396
- const WorkspaceSymbol$2 = 9;
1393
+ const GoToColumn$1 = 4;
1394
+ const GoToLine$2 = 5;
1395
+ const Help$2 = 6;
1396
+ const Recent$1 = 7;
1397
+ const Symbol$2 = 8;
1398
+ const View$3 = 9;
1399
+ const WorkspaceSymbol$2 = 10;
1397
1400
  const EveryThing$1 = 100;
1398
1401
 
1399
1402
  const noop$1 = async () => {};
@@ -1960,6 +1963,7 @@ const GoToLine$1 = ':';
1960
1963
  const View$2 = 'view ';
1961
1964
  const None$1 = '';
1962
1965
  const Help$1 = '?';
1966
+ const GoToColumn = '::';
1963
1967
 
1964
1968
  const getQuickPickPrefix = value => {
1965
1969
  if (value.startsWith(Command)) {
@@ -1971,6 +1975,9 @@ const getQuickPickPrefix = value => {
1971
1975
  if (value.startsWith(WorkspaceSymbol$1)) {
1972
1976
  return WorkspaceSymbol$1;
1973
1977
  }
1978
+ if (value.startsWith(GoToColumn)) {
1979
+ return GoToColumn;
1980
+ }
1974
1981
  if (value.startsWith(GoToLine$1)) {
1975
1982
  return GoToLine$1;
1976
1983
  }
@@ -1988,16 +1995,18 @@ const getFilterValueEverything = value => {
1988
1995
  const prefixLength = prefix.length;
1989
1996
  return value.slice(prefixLength).trim();
1990
1997
  };
1998
+ const getValueGoToColumn = value => {
1999
+ return '';
2000
+ };
1991
2001
  const getValueGoToLine = value => {
1992
- if (value.startsWith('::')) {
1993
- return value.slice(2);
1994
- }
1995
- return value.slice(1);
2002
+ return '';
1996
2003
  };
1997
2004
  const getFn$1 = id => {
1998
2005
  switch (id) {
1999
2006
  case EveryThing$1:
2000
2007
  return getFilterValueEverything;
2008
+ case GoToColumn$1:
2009
+ return getValueGoToColumn;
2001
2010
  case GoToLine$2:
2002
2011
  return getValueGoToLine;
2003
2012
  default:
@@ -2005,8 +2014,11 @@ const getFn$1 = id => {
2005
2014
  }
2006
2015
  };
2007
2016
  const getFilterValue = (id, subId, value) => {
2017
+ if (subId === GoToColumn$1) {
2018
+ return getValueGoToColumn();
2019
+ }
2008
2020
  if (subId === GoToLine$2) {
2009
- return getValueGoToLine(value);
2021
+ return getValueGoToLine();
2010
2022
  }
2011
2023
  const fn = getFn$1(id);
2012
2024
  const filterValue = fn(value);
@@ -2056,10 +2068,18 @@ const handleError = async (error, notify = true, prefix = '') => {
2056
2068
  console.error(error);
2057
2069
  };
2058
2070
  const showErrorDialog = async error => {
2059
- const code = error.code;
2060
- const message = error.message;
2061
- const stack = error.stack;
2062
- const name = error.name;
2071
+ const {
2072
+ code
2073
+ } = error;
2074
+ const {
2075
+ message
2076
+ } = error;
2077
+ const {
2078
+ stack
2079
+ } = error;
2080
+ const {
2081
+ name
2082
+ } = error;
2063
2083
  const errorInfo = {
2064
2084
  code,
2065
2085
  message,
@@ -2251,6 +2271,26 @@ const getPicks$9 = async searchValue => {
2251
2271
  return picks;
2252
2272
  };
2253
2273
 
2274
+ const getText = async () => {
2275
+ // TODO
2276
+ const id = await getActiveEditorId();
2277
+ const lines = await getLines(id);
2278
+ return lines.join('\n');
2279
+ };
2280
+
2281
+ const getPicksGoToColumnBase = async () => {
2282
+ const text = await getText();
2283
+ return [{
2284
+ description: '',
2285
+ direntType: 0,
2286
+ fileIcon: '',
2287
+ icon: '',
2288
+ label: `Type a character position to go to (from 1 to ${text.length})`,
2289
+ matches: [],
2290
+ uri: ''
2291
+ }];
2292
+ };
2293
+
2254
2294
  const getPosition = (text, wantedColumn) => {
2255
2295
  let row = 0;
2256
2296
  let column = 0;
@@ -2268,99 +2308,6 @@ const getPosition = (text, wantedColumn) => {
2268
2308
  };
2269
2309
  };
2270
2310
 
2271
- const getText = async () => {
2272
- // TODO
2273
- const id = await getActiveEditorId();
2274
- const lines = await getLines(id);
2275
- return lines.join('\n');
2276
- };
2277
-
2278
- const getPicks$8 = async value => {
2279
- if (value === '::') {
2280
- const text = await getText();
2281
- return [{
2282
- description: '',
2283
- direntType: 0,
2284
- fileIcon: '',
2285
- icon: '',
2286
- label: `Type a character position to go to (from 1 to ${text.length})`,
2287
- matches: [],
2288
- uri: ''
2289
- }];
2290
- }
2291
- if (value.startsWith('::')) {
2292
- const columnString = value.slice(2);
2293
- const wantedColumn = Number.parseInt(columnString, 10);
2294
- const text = await getText();
2295
- const position = getPosition(text, wantedColumn);
2296
- return [{
2297
- description: '',
2298
- direntType: 0,
2299
- fileIcon: '',
2300
- icon: '',
2301
- label: `Press 'Enter' to go to line ${position.row} column ${position.column}`,
2302
- matches: [],
2303
- uri: ''
2304
- }];
2305
- }
2306
- const picks = [{
2307
- description: '',
2308
- direntType: None$2,
2309
- fileIcon: '',
2310
- icon: '',
2311
- label: '1',
2312
- matches: [],
2313
- uri: ''
2314
- }, {
2315
- description: '',
2316
- direntType: None$2,
2317
- fileIcon: '',
2318
- icon: '',
2319
- label: '2',
2320
- matches: [],
2321
- uri: ''
2322
- }, {
2323
- description: '',
2324
- direntType: None$2,
2325
- fileIcon: '',
2326
- icon: '',
2327
- label: '3',
2328
- matches: [],
2329
- uri: ''
2330
- }, {
2331
- description: '',
2332
- direntType: None$2,
2333
- fileIcon: '',
2334
- icon: '',
2335
- label: '4',
2336
- matches: [],
2337
- uri: ''
2338
- }, {
2339
- description: '',
2340
- direntType: None$2,
2341
- fileIcon: '',
2342
- icon: '',
2343
- label: '5',
2344
- matches: [],
2345
- uri: ''
2346
- }, {
2347
- description: '',
2348
- direntType: None$2,
2349
- fileIcon: '',
2350
- icon: '',
2351
- label: '6',
2352
- matches: [],
2353
- uri: ''
2354
- }];
2355
- return picks;
2356
- };
2357
-
2358
- const DotDotDot = '...';
2359
- const Colon = ':';
2360
- const Percent = '%';
2361
- const AngleBracket = '>';
2362
- const View$1 = 'view';
2363
-
2364
2311
  const emptyObject = {};
2365
2312
  const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
2366
2313
  const i18nString = (key, placeholders = emptyObject) => {
@@ -2382,7 +2329,14 @@ const QuickOpen = 'Quick open';
2382
2329
  const SearchForText = 'Search for text';
2383
2330
  const ShowAndRunCommands = 'Show And Run Commands';
2384
2331
  const TypeNameOfCommandToRun = 'Type the name of a command to run.';
2332
+ const PressEnterToGoToLine = `Press 'Enter' to go to line {PH1} column {PH2}`;
2385
2333
 
2334
+ const pressEnterToGoToLine = (row, column) => {
2335
+ return i18nString(PressEnterToGoToLine, {
2336
+ PH1: row,
2337
+ PH2: column
2338
+ });
2339
+ };
2386
2340
  const typeNameofCommandToRun = () => {
2387
2341
  return i18nString(TypeNameOfCommandToRun);
2388
2342
  };
@@ -2411,6 +2365,84 @@ const openView = () => {
2411
2365
  return i18nString(OpenView);
2412
2366
  };
2413
2367
 
2368
+ const getPicksGoToColumn = async value => {
2369
+ if (value === GoToColumn) {
2370
+ return getPicksGoToColumnBase();
2371
+ }
2372
+ if (value.startsWith(GoToColumn)) {
2373
+ const columnString = value.slice(GoToColumn.length);
2374
+ const wantedColumn = Number.parseInt(columnString, 10);
2375
+ if (Number.isNaN(wantedColumn)) {
2376
+ return getPicksGoToColumnBase();
2377
+ }
2378
+ const text = await getText();
2379
+ const position = getPosition(text, wantedColumn);
2380
+ return [{
2381
+ description: '',
2382
+ direntType: 0,
2383
+ fileIcon: '',
2384
+ icon: '',
2385
+ label: pressEnterToGoToLine(position.row, position.column),
2386
+ matches: [],
2387
+ uri: ''
2388
+ }];
2389
+ }
2390
+ return [];
2391
+ };
2392
+
2393
+ const splitLines = lines => {
2394
+ if (!lines) {
2395
+ return [];
2396
+ }
2397
+ return lines.split('\n');
2398
+ };
2399
+
2400
+ const getPicksGoToLineBase = async () => {
2401
+ const text = await getText();
2402
+ const lines = splitLines(text);
2403
+ const lineCount = lines.length;
2404
+ return [{
2405
+ description: '',
2406
+ direntType: 0,
2407
+ fileIcon: '',
2408
+ icon: '',
2409
+ label: `Type a line number to go to (from 1 to ${lineCount})`,
2410
+ matches: [],
2411
+ uri: ''
2412
+ }];
2413
+ };
2414
+
2415
+ const getPicks$8 = async value => {
2416
+ if (value === GoToLine$1) {
2417
+ return getPicksGoToLineBase();
2418
+ }
2419
+ if (value.startsWith(GoToLine$1)) {
2420
+ const lineString = value.slice(GoToLine$1.length);
2421
+ const wantedLine = Number.parseInt(lineString, 10);
2422
+ if (Number.isNaN(wantedLine)) {
2423
+ return getPicksGoToLineBase();
2424
+ }
2425
+ const rowIndex = wantedLine - 1;
2426
+ const columnIndex = 0;
2427
+ return [{
2428
+ description: '',
2429
+ direntType: 0,
2430
+ fileIcon: '',
2431
+ icon: '',
2432
+ label: pressEnterToGoToLine(rowIndex, columnIndex),
2433
+ matches: [],
2434
+ uri: ''
2435
+ }];
2436
+ }
2437
+ return [];
2438
+ };
2439
+
2440
+ const DotDotDot = '...';
2441
+ const Colon = ':';
2442
+ const Percent = '%';
2443
+ const AngleBracket = '>';
2444
+ const View$1 = 'view';
2445
+
2414
2446
  const getPicks$7 = async () => {
2415
2447
  return [{
2416
2448
  description: goToFile(),
@@ -2553,7 +2585,9 @@ const selectPickExtension = async item => {
2553
2585
  };
2554
2586
  const selectPick$8 = async item => {
2555
2587
  // @ts-ignore
2556
- const id = item.id;
2588
+ const {
2589
+ id
2590
+ } = item;
2557
2591
  if (id.startsWith('ext.')) {
2558
2592
  return selectPickExtension(item);
2559
2593
  }
@@ -2580,7 +2614,9 @@ const openUri = async uri => {
2580
2614
  };
2581
2615
 
2582
2616
  const selectPick$6 = async pick => {
2583
- const description = pick.description;
2617
+ const {
2618
+ description
2619
+ } = pick;
2584
2620
  const fileName = pick.label;
2585
2621
  const workspace = await getWorkspacePath();
2586
2622
  const absolutePath = `${workspace}/${description}/${fileName}`;
@@ -2599,8 +2635,8 @@ const goToPositionAndFocus = async (rowIndex, columnIndex) => {
2599
2635
  await invoke$1('Editor.handleFocus');
2600
2636
  };
2601
2637
 
2602
- const selectPick$5 = async (item, value) => {
2603
- if (value.startsWith('::')) {
2638
+ const selectPickGoToColumn = async (item, value) => {
2639
+ if (value.startsWith(GoToColumn)) {
2604
2640
  const columnString = value.slice(2);
2605
2641
  const wantedColumn = Number.parseInt(columnString, 10);
2606
2642
  const text = await getText();
@@ -2610,9 +2646,22 @@ const selectPick$5 = async (item, value) => {
2610
2646
  command: Hide
2611
2647
  };
2612
2648
  }
2613
- const rowIndex = Number.parseInt(item.label);
2614
- const columnIndex = 0;
2615
- await goToPositionAndFocus(rowIndex, columnIndex);
2649
+ return {
2650
+ command: Hide
2651
+ };
2652
+ };
2653
+
2654
+ const selectPick$5 = async (item, value) => {
2655
+ if (value.startsWith(GoToLine$1)) {
2656
+ const lineString = value.slice(GoToLine$1.length);
2657
+ const wantedLine = Number.parseInt(lineString, 10);
2658
+ const rowIndex = wantedLine - 1;
2659
+ const columnIndex = 0;
2660
+ await goToPositionAndFocus(rowIndex, columnIndex);
2661
+ return {
2662
+ command: Hide
2663
+ };
2664
+ }
2616
2665
  return {
2617
2666
  command: Hide
2618
2667
  };
@@ -2659,8 +2708,8 @@ const selectPick = async item => {
2659
2708
  };
2660
2709
  };
2661
2710
 
2662
- const selectPicks = [selectPick$9, selectPick$8, selectPick$7, selectPick$6, selectPick$5, selectPick$4, selectPick$3, selectPick$2, selectPick$1, selectPick];
2663
- const getPicks$2 = [getPicks$c, getPicks$b, getPicks$a, getPicks$9, getPicks$8, getPicks$7, getPicks$6, getPicks$5, getPicks$4, getPicks$3];
2711
+ const selectPicks = [selectPick$9, selectPick$8, selectPick$7, selectPick$6, selectPickGoToColumn, selectPick$5, selectPick$4, selectPick$3, selectPick$2, selectPick$1, selectPick];
2712
+ const getPicks$2 = [getPicks$c, getPicks$b, getPicks$a, getPicks$9, getPicksGoToColumn, getPicks$8, getPicks$7, getPicks$6, getPicks$5, getPicks$4, getPicks$3];
2664
2713
 
2665
2714
  const select = selectPicks;
2666
2715
  const getPick$1 = getPicks$2;
@@ -2685,6 +2734,8 @@ const getQuickPickSubProviderId = (id, prefix) => {
2685
2734
  switch (prefix) {
2686
2735
  case Command:
2687
2736
  return Commands$1;
2737
+ case GoToColumn:
2738
+ return GoToColumn$1;
2688
2739
  case GoToLine$1:
2689
2740
  return GoToLine$2;
2690
2741
  case Help$1:
@@ -2848,8 +2899,6 @@ const handleClickAt = (state, x, y) => {
2848
2899
  return selectIndex(state, index);
2849
2900
  };
2850
2901
 
2851
- const setFocus = setFocus$1;
2852
-
2853
2902
  const handleFocus = async state => {
2854
2903
  // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2855
2904
  await setFocus(FocusQuickPickInput);
@@ -3488,13 +3537,6 @@ const invoke = (method, ...params) => {
3488
3537
  return invoke$1('SearchProcess.invoke', method, ...params);
3489
3538
  };
3490
3539
 
3491
- const splitLines = lines => {
3492
- if (!lines) {
3493
- return [];
3494
- }
3495
- return lines.split('\n');
3496
- };
3497
-
3498
3540
  // TODO create direct connection from electron to file search worker using message ports
3499
3541
 
3500
3542
  const searchFile = async (path, value, prepare) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "6.10.0",
3
+ "version": "6.12.0",
4
4
  "keywords": [
5
5
  "text-search"
6
6
  ],