@lvce-editor/file-search-worker 6.8.0 → 6.9.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.
@@ -2648,6 +2648,23 @@ const getPicks$9 = async searchValue => {
2648
2648
  return picks;
2649
2649
  };
2650
2650
 
2651
+ const getPosition = (text, wantedColumn) => {
2652
+ let row = 0;
2653
+ let column = 0;
2654
+ for (let i = 0; i < wantedColumn; i++) {
2655
+ if (text[i] === '\n') {
2656
+ row++;
2657
+ column = 0;
2658
+ } else {
2659
+ column++;
2660
+ }
2661
+ }
2662
+ return {
2663
+ column,
2664
+ row
2665
+ };
2666
+ };
2667
+
2651
2668
  const getText = async () => {
2652
2669
  // TODO
2653
2670
  const id = await getActiveEditorId();
@@ -2655,23 +2672,33 @@ const getText = async () => {
2655
2672
  return lines.join('\n');
2656
2673
  };
2657
2674
 
2658
- const toPick = column => {
2659
- return {
2660
- description: '',
2661
- direntType: None$2,
2662
- fileIcon: '',
2663
- icon: '',
2664
- label: `${column}`,
2665
- matches: [],
2666
- uri: ''
2667
- };
2668
- };
2669
2675
  const getPicks$8 = async value => {
2676
+ if (value === '::') {
2677
+ const text = await getText();
2678
+ return [{
2679
+ description: '',
2680
+ direntType: 0,
2681
+ fileIcon: '',
2682
+ icon: '',
2683
+ label: `Type a character position to go to (from 1 to ${text.length})`,
2684
+ matches: [],
2685
+ uri: ''
2686
+ }];
2687
+ }
2670
2688
  if (value.startsWith('::')) {
2689
+ const columnString = value.slice(2);
2690
+ const wantedColumn = Number.parseInt(columnString, 10);
2671
2691
  const text = await getText();
2672
- const columns = [...Array(text.length).fill(0)].map((item, index) => index);
2673
- const picks = columns.map(toPick);
2674
- return picks;
2692
+ const position = getPosition(text, wantedColumn);
2693
+ return [{
2694
+ description: '',
2695
+ direntType: 0,
2696
+ fileIcon: '',
2697
+ icon: '',
2698
+ label: `Press 'Enter' to go to line ${position.row} column ${position.column}`,
2699
+ matches: [],
2700
+ uri: ''
2701
+ }];
2675
2702
  }
2676
2703
  const picks = [{
2677
2704
  description: '',
@@ -2961,22 +2988,6 @@ const setCursor = async (rowIndex, columnIndex) => {
2961
2988
  await invoke$2('Editor.cursorSet', rowIndex, columnIndex);
2962
2989
  };
2963
2990
 
2964
- const getPosition = (text, wantedColumn) => {
2965
- let row = 0;
2966
- let column = 0;
2967
- for (let i = 0; i < wantedColumn; i++) {
2968
- if (text[i] === '\n') {
2969
- row++;
2970
- column = 0;
2971
- } else {
2972
- column++;
2973
- }
2974
- }
2975
- return {
2976
- column,
2977
- row
2978
- };
2979
- };
2980
2991
  const goToPositionAndFocus = async (rowIndex, columnIndex) => {
2981
2992
  await setCursor(rowIndex, columnIndex);
2982
2993
  await invoke$2('Editor.handleFocus');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "6.8.0",
3
+ "version": "6.9.0",
4
4
  "keywords": [
5
5
  "text-search"
6
6
  ],