@lvce-editor/explorer-view 6.4.0 → 6.6.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.
@@ -927,6 +927,7 @@ const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
927
927
  const Copy = 'Copy';
928
928
  const CopyPath = 'Copy Path';
929
929
  const CopyRelativePath = 'Copy Relative Path';
930
+ const CompareWithSelected = 'Compare with Selected';
930
931
  const Cut = 'Cut';
931
932
  const Delete = 'Delete';
932
933
  const FileNameCannotStartWithSlash = 'A file or folder name cannot start with a slash.';
@@ -944,6 +945,7 @@ const Paste = 'Paste';
944
945
  const RefreshExplorer = 'Refresh Explorer';
945
946
  const RemoveFolderFromWorkspace = 'Remove folder from workspace';
946
947
  const Rename = 'Rename';
948
+ const SelectForCompare = 'Select for Compare';
947
949
  const TheNameIsNotValid = 'The name **{0}** is not valid as a file or folder name. Please choose a different name.';
948
950
  const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
949
951
  const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder.';
@@ -975,6 +977,12 @@ const copyPath$1 = () => {
975
977
  const copyRelativePath$1 = () => {
976
978
  return i18nString(CopyRelativePath);
977
979
  };
980
+ const compareWithSelected$1 = () => {
981
+ return i18nString(CompareWithSelected);
982
+ };
983
+ const selectForCompare$1 = () => {
984
+ return i18nString(SelectForCompare);
985
+ };
978
986
  const rename = () => {
979
987
  return i18nString(Rename);
980
988
  };
@@ -1321,6 +1329,36 @@ const collapseAll = async state => {
1321
1329
  };
1322
1330
  };
1323
1331
 
1332
+ const getFocusedFile = state => {
1333
+ if (state.focusedIndex < 0 || state.focusedIndex >= state.items.length) {
1334
+ return undefined;
1335
+ }
1336
+ const item = state.items[state.focusedIndex];
1337
+ if (item.type !== File) {
1338
+ return undefined;
1339
+ }
1340
+ return item;
1341
+ };
1342
+
1343
+ const openDiff = async (leftUri, rightUri, focus) => {
1344
+ await openUri$1(`diff://${leftUri}<->${rightUri}`, focus);
1345
+ };
1346
+
1347
+ const compareWithSelected = async state => {
1348
+ const focusedFile = getFocusedFile(state);
1349
+ if (!focusedFile) {
1350
+ return state;
1351
+ }
1352
+ if (!state.compareSourceUri || state.compareSourceUri === focusedFile.path) {
1353
+ return state;
1354
+ }
1355
+ await openDiff(state.compareSourceUri, focusedFile.path, true);
1356
+ return {
1357
+ ...state,
1358
+ compareSourceUri: ''
1359
+ };
1360
+ };
1361
+
1324
1362
  const getFocusedDirent$1 = state => {
1325
1363
  const {
1326
1364
  focusedIndex,
@@ -2021,6 +2059,7 @@ const Slash = '/';
2021
2059
  const create$8 = (id, uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '') => {
2022
2060
  const state = {
2023
2061
  assetDir,
2062
+ compareSourceUri: '',
2024
2063
  confirmDelete: false,
2025
2064
  confirmPaste: false,
2026
2065
  cutItems: [],
@@ -2560,6 +2599,18 @@ const menuEntryCopyRelativePath = {
2560
2599
  id: 'copyRelativePath',
2561
2600
  label: copyRelativePath$1()
2562
2601
  };
2602
+ const menuEntrySelectForCompare = {
2603
+ command: 'Explorer.selectForCompare',
2604
+ flags: RestoreFocus,
2605
+ id: 'selectForCompare',
2606
+ label: selectForCompare$1()
2607
+ };
2608
+ const menuEntryCompareWithSelected = {
2609
+ command: 'Explorer.compareWithSelected',
2610
+ flags: RestoreFocus,
2611
+ id: 'compareWithSelected',
2612
+ label: compareWithSelected$1()
2613
+ };
2563
2614
  const menuEntryRename = {
2564
2615
  command: 'Explorer.renameDirent',
2565
2616
  flags: None$2,
@@ -2593,7 +2644,10 @@ const getMenuEntriesDirectory = () => {
2593
2644
  return ALL_ENTRIES;
2594
2645
  };
2595
2646
  const getMenuEntriesFile = () => {
2596
- return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryRename, menuEntryDelete];
2647
+ return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntrySelectForCompare, menuEntrySeparator, menuEntryRename, menuEntryDelete];
2648
+ };
2649
+ const getMenuEntriesFileCompareWithSelected = () => {
2650
+ return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryCompareWithSelected, menuEntrySeparator, menuEntryRename, menuEntryDelete];
2597
2651
  };
2598
2652
  const getMenuEntriesDefault = () => {
2599
2653
  return ALL_ENTRIES;
@@ -2614,6 +2668,9 @@ const getMenuEntries = state => {
2614
2668
  case Directory:
2615
2669
  return getMenuEntriesDirectory();
2616
2670
  case File:
2671
+ if (state.compareSourceUri && state.compareSourceUri !== focusedDirent.path) {
2672
+ return getMenuEntriesFileCompareWithSelected();
2673
+ }
2617
2674
  return getMenuEntriesFile();
2618
2675
  default:
2619
2676
  return getMenuEntriesDefault();
@@ -4204,8 +4261,12 @@ const handleIconThemeChange = state => {
4204
4261
  const handleInputBlur = async state => {
4205
4262
  const {
4206
4263
  editingErrorMessage,
4264
+ editingIndex,
4207
4265
  editingValue
4208
4266
  } = state;
4267
+ if (editingIndex === -1) {
4268
+ return state;
4269
+ }
4209
4270
  if (editingErrorMessage || !editingValue) {
4210
4271
  return cancelEditInternal(state, false);
4211
4272
  }
@@ -5727,6 +5788,17 @@ const selectDown = state => {
5727
5788
  };
5728
5789
  };
5729
5790
 
5791
+ const selectForCompare = state => {
5792
+ const focusedFile = getFocusedFile(state);
5793
+ if (!focusedFile) {
5794
+ return state;
5795
+ }
5796
+ return {
5797
+ ...state,
5798
+ compareSourceUri: focusedFile.path
5799
+ };
5800
+ };
5801
+
5730
5802
  const setSelectedIndices = (state, indices) => {
5731
5803
  const {
5732
5804
  items
@@ -5814,6 +5886,7 @@ const commandMap = {
5814
5886
  'Explorer.cancelEdit': wrapListItemCommand(cancelEdit),
5815
5887
  'Explorer.cancelTypeAhead': wrapListItemCommand(cancelTypeAhead),
5816
5888
  'Explorer.collapseAll': wrapListItemCommand(collapseAll),
5889
+ 'Explorer.compareWithSelected': wrapListItemCommand(compareWithSelected),
5817
5890
  'Explorer.copyPath': wrapListItemCommand(copyPath),
5818
5891
  'Explorer.copyRelativePath': wrapListItemCommand(copyRelativePath),
5819
5892
  'Explorer.create': create$8,
@@ -5885,6 +5958,7 @@ const commandMap = {
5885
5958
  'Explorer.saveState': wrapGetter(saveState),
5886
5959
  'Explorer.selectAll': wrapListItemCommand(selectAll),
5887
5960
  'Explorer.selectDown': wrapListItemCommand(selectDown),
5961
+ 'Explorer.selectForCompare': wrapListItemCommand(selectForCompare),
5888
5962
  'Explorer.selectIndices': wrapListItemCommand(setSelectedIndices),
5889
5963
  'Explorer.selectUp': wrapListItemCommand(selectUp),
5890
5964
  'Explorer.setDeltaY': wrapListItemCommand(setDeltaY),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",