@codingame/monaco-vscode-api 2.1.4 → 2.2.0-next.2

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.
Files changed (194) hide show
  1. package/README.md +24 -0
  2. package/contributions.js +1 -0
  3. package/extensions.d.ts +7 -3
  4. package/extensions.js +28 -8
  5. package/lifecycle.js +11 -3
  6. package/localExtensionHost.js +13 -10
  7. package/missing-services.js +55 -10
  8. package/monaco.js +7 -3
  9. package/package.json +8 -8
  10. package/service-override/tools/views.d.ts +98 -0
  11. package/service-override/tools/views.js +249 -0
  12. package/services.d.ts +4 -2
  13. package/services.js +11 -9
  14. package/vscode/src/vs/base/browser/deviceAccess.js +60 -0
  15. package/vscode/src/vs/base/browser/dom.js +18 -1
  16. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +178 -0
  17. package/vscode/src/vs/base/browser/ui/grid/grid.js +492 -0
  18. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +4 -0
  19. package/vscode/src/vs/base/browser/ui/grid/gridview.d.ts +1 -0
  20. package/vscode/src/vs/base/browser/ui/grid/gridview.js +1109 -0
  21. package/vscode/src/vs/base/browser/ui/sash/sash.js +9 -1
  22. package/vscode/src/vs/base/browser/ui/splitview/splitview.d.ts +348 -1
  23. package/vscode/src/vs/base/common/async.js +46 -2
  24. package/vscode/src/vs/base/common/codicons.d.ts +579 -0
  25. package/vscode/src/vs/base/common/event.js +11 -2
  26. package/vscode/src/vs/base/common/keybindingParser.js +87 -0
  27. package/vscode/src/vs/base/common/network.js +1 -2
  28. package/vscode/src/vs/base/common/observableInternal/utils.js +1 -1
  29. package/vscode/src/vs/base/common/platform.js +2 -1
  30. package/vscode/src/vs/base/common/scrollable.d.ts +28 -0
  31. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/colors.js +17 -0
  32. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/diffEditorItemTemplate.js +214 -0
  33. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel.js +84 -0
  34. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget.js +54 -0
  35. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidgetImpl.js +324 -0
  36. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/objectPool.js +46 -0
  37. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/style.css.js +4 -0
  38. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/utils.js +11 -0
  39. package/vscode/src/vs/platform/keyboardLayout/common/keyboardLayout.js +61 -1
  40. package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +10 -0
  41. package/vscode/src/vs/platform/log/browser/log.js +24 -0
  42. package/vscode/src/vs/platform/product/common/product.js +1 -2
  43. package/vscode/src/vs/platform/userDataSync/common/abstractSynchronizer.js +772 -0
  44. package/vscode/src/vs/platform/userDataSync/common/userDataSyncStoreService.js +551 -0
  45. package/vscode/src/vs/platform/webview/common/mimeTypes.js +22 -0
  46. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +62 -0
  47. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +788 -0
  48. package/vscode/src/vs/workbench/browser/actions/listCommands.js +763 -0
  49. package/vscode/src/vs/workbench/browser/layout.d.ts +26 -0
  50. package/vscode/src/vs/workbench/browser/media/style.css.js +1 -1
  51. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +610 -0
  52. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +4 -0
  53. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +4 -0
  54. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +148 -0
  55. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +4 -0
  56. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +603 -0
  57. package/vscode/src/vs/workbench/browser/parts/compositePart.js +333 -0
  58. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +221 -0
  59. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1406 -0
  60. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +184 -0
  61. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +509 -0
  62. package/vscode/src/vs/workbench/browser/parts/editor/editorPane.d.ts +112 -0
  63. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1018 -0
  64. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +389 -0
  65. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +4 -0
  66. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +4 -0
  67. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +4 -0
  68. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsActions.css.js +4 -0
  69. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsCenter.css.js +4 -0
  70. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsList.css.js +4 -0
  71. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsToasts.css.js +4 -0
  72. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +213 -0
  73. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js +73 -0
  74. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +307 -0
  75. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.js +226 -0
  76. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +218 -0
  77. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +433 -0
  78. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +436 -0
  79. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
  80. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +377 -0
  81. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +66 -0
  82. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +144 -0
  83. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +4 -0
  84. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +220 -0
  85. package/vscode/src/vs/workbench/browser/window.js +239 -5
  86. package/vscode/src/vs/workbench/common/configuration.js +11 -1
  87. package/vscode/src/vs/workbench/common/theme.js +3 -3
  88. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +298 -0
  89. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +363 -0
  90. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +133 -0
  91. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +4 -0
  92. package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +90 -0
  93. package/vscode/src/vs/workbench/contrib/comments/browser/commentMenus.js +43 -0
  94. package/vscode/src/vs/workbench/contrib/comments/browser/commentService.js +317 -2
  95. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +107 -0
  96. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +395 -0
  97. package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +3 -0
  98. package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +1277 -0
  99. package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +17 -0
  100. package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +123 -0
  101. package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +342 -0
  102. package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +451 -0
  103. package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +176 -0
  104. package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +4 -0
  105. package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +35 -0
  106. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +16 -0
  107. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +143 -0
  108. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +212 -0
  109. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +4 -0
  110. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +76 -0
  111. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +61 -0
  112. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +117 -0
  113. package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.js +62 -0
  114. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +5 -0
  115. package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +77 -0
  116. package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorHandler.js +72 -0
  117. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +254 -0
  118. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +97 -0
  119. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +442 -0
  120. package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +430 -0
  121. package/vscode/src/vs/workbench/contrib/files/browser/explorerViewlet.js +10 -10
  122. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +784 -0
  123. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +487 -0
  124. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +521 -0
  125. package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +150 -0
  126. package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +61 -0
  127. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveDocumentService.js +25 -1
  128. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +178 -0
  129. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +49 -0
  130. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
  131. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +4 -0
  132. package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +145 -0
  133. package/vscode/src/vs/workbench/contrib/mappedEdits/common/mappedEdits.contribution.js +22 -0
  134. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +691 -0
  135. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +238 -0
  136. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +76 -0
  137. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +40 -0
  138. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +69 -0
  139. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +346 -0
  140. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +96 -0
  141. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +144 -0
  142. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +103 -0
  143. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +399 -0
  144. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +195 -0
  145. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +39 -0
  146. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +126 -0
  147. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +4 -0
  148. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +611 -0
  149. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +156 -0
  150. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +262 -0
  151. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +171 -0
  152. package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.js +41 -0
  153. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +317 -0
  154. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +56 -0
  155. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +315 -0
  156. package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +193 -0
  157. package/vscode/src/vs/workbench/contrib/preferences/common/preferences.js +2 -1
  158. package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +2 -2
  159. package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +37 -0
  160. package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +39 -0
  161. package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +138 -2
  162. package/vscode/src/vs/workbench/contrib/tags/browser/workspaceTagsService.js +12 -0
  163. package/vscode/src/vs/workbench/contrib/tags/common/workspaceTags.js +3 -0
  164. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +4 -0
  165. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +281 -0
  166. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +358 -0
  167. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +131 -0
  168. package/vscode/src/vs/workbench/contrib/update/common/update.js +2 -0
  169. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +288 -0
  170. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +94 -0
  171. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +86 -0
  172. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +77 -0
  173. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +646 -0
  174. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +63 -0
  175. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +57 -0
  176. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +140 -0
  177. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +119 -0
  178. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
  179. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +233 -0
  180. package/vscode/src/vs/workbench/contrib/workspace/common/workspace.js +16 -0
  181. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +143 -0
  182. package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +0 -3
  183. package/vscode/src/vs/workbench/services/driver/browser/driver.js +184 -0
  184. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +668 -0
  185. package/vscode/src/vs/workbench/services/history/browser/historyService.js +1482 -0
  186. package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +17 -1
  187. package/vscode/src/vs/workbench/services/lifecycle/common/lifecycle.js +8 -1
  188. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +4 -0
  189. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +521 -0
  190. package/vscode/src/vs/workbench/services/textMate/common/TMGrammars.js +102 -0
  191. package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +296 -0
  192. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +99 -0
  193. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
  194. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +596 -0
@@ -0,0 +1,1482 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from '../../../../nls.js';
3
+ import { URI } from '../../../../base/common/uri.js';
4
+ import { isEditorPaneWithSelection, isEditorInput, EditorResourceAccessor, EditorCloseContext, SideBySideEditor, isSideBySideEditorInput, isResourceEditorInput } from '../../../common/editor.js';
5
+ import { IEditorService } from '../../editor/common/editorService.js';
6
+ import { IHistoryService } from '../common/history.js';
7
+ import { FILES_EXCLUDE_CONFIG, FileChangesEvent, FileOperationEvent, IFileService } from '../../../../platform/files/common/files.js';
8
+ import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
9
+ import { Disposable, DisposableStore, dispose } from '../../../../base/common/lifecycle.js';
10
+ import { IStorageService } from '../../../../platform/storage/common/storage.js';
11
+ import { Emitter, Event } from '../../../../base/common/event.js';
12
+ import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
13
+ import { IEditorGroupsService } from '../../editor/common/editorGroupsService.js';
14
+ import { getExcludes, SEARCH_EXCLUDE_CONFIG } from '../../search/common/search.js';
15
+ import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
16
+ import { IWorkbenchLayoutService } from '../../layout/browser/layoutService.js';
17
+ import { RawContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
18
+ import { coalesce, remove } from '../../../../base/common/arrays.js';
19
+ import { registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
20
+ import { WindowIdleValue, EventHelper, addDisposableListener, EventType } from '../../../../base/browser/dom.js';
21
+ import { IWorkspacesService } from '../../../../platform/workspaces/common/workspaces.js';
22
+ import { Schemas } from '../../../../base/common/network.js';
23
+ import { onUnexpectedError } from '../../../../base/common/errors.js';
24
+ import { ResourceGlobMatcher } from '../../../common/resources.js';
25
+ import { IPathService } from '../../path/common/pathService.js';
26
+ import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js';
27
+ import { ILifecycleService } from '../../lifecycle/common/lifecycle.js';
28
+ import { LogLevel, ILogService } from '../../../../platform/log/common/log.js';
29
+ import { mainWindow } from '../../../../base/browser/window.js';
30
+ var HistoryService_1, EditorNavigationStack_1;
31
+ let HistoryService = class HistoryService extends Disposable {
32
+ static { HistoryService_1 = this; }
33
+ static { this.MOUSE_NAVIGATION_SETTING = 'workbench.editor.mouseBackForwardToNavigate'; }
34
+ static { this.NAVIGATION_SCOPE_SETTING = 'workbench.editor.navigationScope'; }
35
+ constructor(editorService, editorGroupService, contextService, storageService, configurationService, fileService, workspacesService, instantiationService, layoutService, contextKeyService) {
36
+ super();
37
+ this.editorService = editorService;
38
+ this.editorGroupService = editorGroupService;
39
+ this.contextService = contextService;
40
+ this.storageService = storageService;
41
+ this.configurationService = configurationService;
42
+ this.fileService = fileService;
43
+ this.workspacesService = workspacesService;
44
+ this.instantiationService = instantiationService;
45
+ this.layoutService = layoutService;
46
+ this.contextKeyService = contextKeyService;
47
+ this.activeEditorListeners = this._register(( new DisposableStore()));
48
+ this.lastActiveEditor = undefined;
49
+ this.editorHelper = this.instantiationService.createInstance(EditorHelper);
50
+ this.canNavigateBackContextKey = (( new RawContextKey('canNavigateBack', false, ( localizeWithPath(
51
+ 'vs/workbench/services/history/browser/historyService',
52
+ 'canNavigateBack',
53
+ "Whether it is possible to navigate back in editor history"
54
+ ))))).bindTo(this.contextKeyService);
55
+ this.canNavigateForwardContextKey = (( new RawContextKey('canNavigateForward', false, ( localizeWithPath(
56
+ 'vs/workbench/services/history/browser/historyService',
57
+ 'canNavigateForward',
58
+ "Whether it is possible to navigate forward in editor history"
59
+ ))))).bindTo(this.contextKeyService);
60
+ this.canNavigateBackInNavigationsContextKey = (( new RawContextKey('canNavigateBackInNavigationLocations', false, ( localizeWithPath(
61
+ 'vs/workbench/services/history/browser/historyService',
62
+ 'canNavigateBackInNavigationLocations',
63
+ "Whether it is possible to navigate back in editor navigation locations history"
64
+ ))))).bindTo(this.contextKeyService);
65
+ this.canNavigateForwardInNavigationsContextKey = (( new RawContextKey('canNavigateForwardInNavigationLocations', false, ( localizeWithPath(
66
+ 'vs/workbench/services/history/browser/historyService',
67
+ 'canNavigateForwardInNavigationLocations',
68
+ "Whether it is possible to navigate forward in editor navigation locations history"
69
+ ))))).bindTo(this.contextKeyService);
70
+ this.canNavigateToLastNavigationLocationContextKey = (( new RawContextKey('canNavigateToLastNavigationLocation', false, ( localizeWithPath(
71
+ 'vs/workbench/services/history/browser/historyService',
72
+ 'canNavigateToLastNavigationLocation',
73
+ "Whether it is possible to navigate to the last editor navigation location"
74
+ ))))).bindTo(this.contextKeyService);
75
+ this.canNavigateBackInEditsContextKey = (( new RawContextKey('canNavigateBackInEditLocations', false, ( localizeWithPath(
76
+ 'vs/workbench/services/history/browser/historyService',
77
+ 'canNavigateBackInEditLocations',
78
+ "Whether it is possible to navigate back in editor edit locations history"
79
+ ))))).bindTo(this.contextKeyService);
80
+ this.canNavigateForwardInEditsContextKey = (( new RawContextKey('canNavigateForwardInEditLocations', false, ( localizeWithPath(
81
+ 'vs/workbench/services/history/browser/historyService',
82
+ 'canNavigateForwardInEditLocations',
83
+ "Whether it is possible to navigate forward in editor edit locations history"
84
+ ))))).bindTo(this.contextKeyService);
85
+ this.canNavigateToLastEditLocationContextKey = (( new RawContextKey('canNavigateToLastEditLocation', false, ( localizeWithPath(
86
+ 'vs/workbench/services/history/browser/historyService',
87
+ 'canNavigateToLastEditLocation',
88
+ "Whether it is possible to navigate to the last editor edit location"
89
+ ))))).bindTo(this.contextKeyService);
90
+ this.canReopenClosedEditorContextKey = (( new RawContextKey('canReopenClosedEditor', false, ( localizeWithPath(
91
+ 'vs/workbench/services/history/browser/historyService',
92
+ 'canReopenClosedEditor',
93
+ "Whether it is possible to reopen the last closed editor"
94
+ ))))).bindTo(this.contextKeyService);
95
+ this._onDidChangeEditorNavigationStack = this._register(( new Emitter()));
96
+ this.onDidChangeEditorNavigationStack = this._onDidChangeEditorNavigationStack.event;
97
+ this.defaultScopedEditorNavigationStack = undefined;
98
+ this.editorGroupScopedNavigationStacks = ( new Map());
99
+ this.editorScopedNavigationStacks = ( new Map());
100
+ this.editorNavigationScope = 0 ;
101
+ this.recentlyUsedEditorsStack = undefined;
102
+ this.recentlyUsedEditorsStackIndex = 0;
103
+ this.recentlyUsedEditorsInGroupStack = undefined;
104
+ this.recentlyUsedEditorsInGroupStackIndex = 0;
105
+ this.navigatingInRecentlyUsedEditorsStack = false;
106
+ this.navigatingInRecentlyUsedEditorsInGroupStack = false;
107
+ this.recentlyClosedEditors = [];
108
+ this.ignoreEditorCloseEvent = false;
109
+ this.history = undefined;
110
+ this.editorHistoryListeners = ( new Map());
111
+ this.resourceExcludeMatcher = this._register(( new WindowIdleValue(mainWindow, () => {
112
+ const matcher = this._register(this.instantiationService.createInstance(ResourceGlobMatcher, root => getExcludes(root ? this.configurationService.getValue({ resource: root }) : this.configurationService.getValue()) || Object.create(null), event => event.affectsConfiguration(FILES_EXCLUDE_CONFIG) || event.affectsConfiguration(SEARCH_EXCLUDE_CONFIG)));
113
+ this._register(matcher.onExpressionChange(() => this.removeExcludedFromHistory()));
114
+ return matcher;
115
+ })));
116
+ this.registerListeners();
117
+ if (this.editorService.activeEditorPane) {
118
+ this.onDidActiveEditorChange();
119
+ }
120
+ }
121
+ registerListeners() {
122
+ this.registerMouseNavigationListener();
123
+ this._register(this.editorService.onDidActiveEditorChange(() => this.onDidActiveEditorChange()));
124
+ this._register(this.editorService.onDidOpenEditorFail(event => this.remove(event.editor)));
125
+ this._register(this.editorService.onDidCloseEditor(event => this.onDidCloseEditor(event)));
126
+ this._register(this.editorService.onDidMostRecentlyActiveEditorsChange(() => this.handleEditorEventInRecentEditorsStack()));
127
+ this._register(this.editorGroupService.onDidRemoveGroup(e => this.onDidRemoveGroup(e)));
128
+ this._register(this.fileService.onDidFilesChange(event => this.onDidFilesChange(event)));
129
+ this._register(this.fileService.onDidRunOperation(event => this.onDidFilesChange(event)));
130
+ this._register(this.storageService.onWillSaveState(() => this.saveState()));
131
+ this.registerEditorNavigationScopeChangeListener();
132
+ this._register(this.onDidChangeEditorNavigationStack(() => this.updateContextKeys()));
133
+ this._register(this.editorGroupService.onDidChangeActiveGroup(() => this.updateContextKeys()));
134
+ }
135
+ onDidCloseEditor(e) {
136
+ this.handleEditorCloseEventInHistory(e);
137
+ this.handleEditorCloseEventInReopen(e);
138
+ }
139
+ registerMouseNavigationListener() {
140
+ const mouseBackForwardSupportListener = this._register(( new DisposableStore()));
141
+ const handleMouseBackForwardSupport = () => {
142
+ mouseBackForwardSupportListener.clear();
143
+ if (this.configurationService.getValue(HistoryService_1.MOUSE_NAVIGATION_SETTING)) {
144
+ this._register(Event.runAndSubscribe(this.layoutService.onDidAddContainer, ({ container, disposables }) => {
145
+ const eventDisposables = disposables.add(( new DisposableStore()));
146
+ eventDisposables.add(addDisposableListener(container, EventType.MOUSE_DOWN, e => this.onMouseDownOrUp(e, true)));
147
+ eventDisposables.add(addDisposableListener(container, EventType.MOUSE_UP, e => this.onMouseDownOrUp(e, false)));
148
+ mouseBackForwardSupportListener.add(eventDisposables);
149
+ }, { container: this.layoutService.mainContainer, disposables: this._store }));
150
+ }
151
+ };
152
+ this._register(this.configurationService.onDidChangeConfiguration(event => {
153
+ if (event.affectsConfiguration(HistoryService_1.MOUSE_NAVIGATION_SETTING)) {
154
+ handleMouseBackForwardSupport();
155
+ }
156
+ }));
157
+ handleMouseBackForwardSupport();
158
+ }
159
+ onMouseDownOrUp(event, isMouseDown) {
160
+ switch (event.button) {
161
+ case 3:
162
+ EventHelper.stop(event);
163
+ if (isMouseDown) {
164
+ this.goBack();
165
+ }
166
+ break;
167
+ case 4:
168
+ EventHelper.stop(event);
169
+ if (isMouseDown) {
170
+ this.goForward();
171
+ }
172
+ break;
173
+ }
174
+ }
175
+ onDidRemoveGroup(group) {
176
+ this.handleEditorGroupRemoveInNavigationStacks(group);
177
+ }
178
+ onDidActiveEditorChange() {
179
+ const activeEditorGroup = this.editorGroupService.activeGroup;
180
+ const activeEditorPane = activeEditorGroup.activeEditorPane;
181
+ if (this.lastActiveEditor && this.editorHelper.matchesEditorIdentifier(this.lastActiveEditor, activeEditorPane)) {
182
+ return;
183
+ }
184
+ this.lastActiveEditor = activeEditorPane?.input && activeEditorPane.group ? { editor: activeEditorPane.input, groupId: activeEditorPane.group.id } : undefined;
185
+ this.activeEditorListeners.clear();
186
+ this.handleActiveEditorChange(activeEditorGroup, activeEditorPane);
187
+ if (isEditorPaneWithSelection(activeEditorPane)) {
188
+ this.activeEditorListeners.add(activeEditorPane.onDidChangeSelection(e => this.handleActiveEditorSelectionChangeEvent(activeEditorGroup, activeEditorPane, e)));
189
+ }
190
+ this.updateContextKeys();
191
+ }
192
+ onDidFilesChange(event) {
193
+ if (event instanceof FileChangesEvent) {
194
+ if (event.gotDeleted()) {
195
+ this.remove(event);
196
+ }
197
+ }
198
+ else {
199
+ if (event.isOperation(1 )) {
200
+ this.remove(event);
201
+ }
202
+ else if (event.isOperation(2 ) && event.target.isFile) {
203
+ this.move(event);
204
+ }
205
+ }
206
+ }
207
+ handleActiveEditorChange(group, editorPane) {
208
+ this.handleActiveEditorChangeInHistory(editorPane);
209
+ this.handleActiveEditorChangeInNavigationStacks(group, editorPane);
210
+ }
211
+ handleActiveEditorSelectionChangeEvent(group, editorPane, event) {
212
+ this.handleActiveEditorSelectionChangeInNavigationStacks(group, editorPane, event);
213
+ }
214
+ move(event) {
215
+ this.moveInHistory(event);
216
+ this.moveInEditorNavigationStacks(event);
217
+ }
218
+ remove(arg1) {
219
+ this.removeFromHistory(arg1);
220
+ this.removeFromEditorNavigationStacks(arg1);
221
+ this.removeFromRecentlyClosedEditors(arg1);
222
+ this.removeFromRecentlyOpened(arg1);
223
+ }
224
+ removeFromRecentlyOpened(arg1) {
225
+ let resource = undefined;
226
+ if (isEditorInput(arg1)) {
227
+ resource = EditorResourceAccessor.getOriginalUri(arg1);
228
+ }
229
+ else if (arg1 instanceof FileChangesEvent) ;
230
+ else {
231
+ resource = arg1.resource;
232
+ }
233
+ if (resource) {
234
+ this.workspacesService.removeRecentlyOpened([resource]);
235
+ }
236
+ }
237
+ clear() {
238
+ this.clearRecentlyOpened();
239
+ this.clearEditorNavigationStacks();
240
+ this.recentlyClosedEditors = [];
241
+ this.updateContextKeys();
242
+ }
243
+ updateContextKeys() {
244
+ this.contextKeyService.bufferChangeEvents(() => {
245
+ const activeStack = this.getStack();
246
+ this.canNavigateBackContextKey.set(activeStack.canGoBack(0 ));
247
+ this.canNavigateForwardContextKey.set(activeStack.canGoForward(0 ));
248
+ this.canNavigateBackInNavigationsContextKey.set(activeStack.canGoBack(2 ));
249
+ this.canNavigateForwardInNavigationsContextKey.set(activeStack.canGoForward(2 ));
250
+ this.canNavigateToLastNavigationLocationContextKey.set(activeStack.canGoLast(2 ));
251
+ this.canNavigateBackInEditsContextKey.set(activeStack.canGoBack(1 ));
252
+ this.canNavigateForwardInEditsContextKey.set(activeStack.canGoForward(1 ));
253
+ this.canNavigateToLastEditLocationContextKey.set(activeStack.canGoLast(1 ));
254
+ this.canReopenClosedEditorContextKey.set(this.recentlyClosedEditors.length > 0);
255
+ });
256
+ }
257
+ registerEditorNavigationScopeChangeListener() {
258
+ const handleEditorNavigationScopeChange = () => {
259
+ this.disposeEditorNavigationStacks();
260
+ const configuredScope = this.configurationService.getValue(HistoryService_1.NAVIGATION_SCOPE_SETTING);
261
+ if (configuredScope === 'editorGroup') {
262
+ this.editorNavigationScope = 1 ;
263
+ }
264
+ else if (configuredScope === 'editor') {
265
+ this.editorNavigationScope = 2 ;
266
+ }
267
+ else {
268
+ this.editorNavigationScope = 0 ;
269
+ }
270
+ };
271
+ this._register(this.configurationService.onDidChangeConfiguration(event => {
272
+ if (event.affectsConfiguration(HistoryService_1.NAVIGATION_SCOPE_SETTING)) {
273
+ handleEditorNavigationScopeChange();
274
+ }
275
+ }));
276
+ handleEditorNavigationScopeChange();
277
+ }
278
+ getStack(group = this.editorGroupService.activeGroup, editor = group.activeEditor) {
279
+ switch (this.editorNavigationScope) {
280
+ case 2 : {
281
+ if (!editor) {
282
+ return ( new NoOpEditorNavigationStacks());
283
+ }
284
+ let stacksForGroup = this.editorScopedNavigationStacks.get(group.id);
285
+ if (!stacksForGroup) {
286
+ stacksForGroup = ( new Map());
287
+ this.editorScopedNavigationStacks.set(group.id, stacksForGroup);
288
+ }
289
+ let stack = stacksForGroup.get(editor)?.stack;
290
+ if (!stack) {
291
+ const disposable = ( new DisposableStore());
292
+ stack = disposable.add(this.instantiationService.createInstance(EditorNavigationStacks, 2 ));
293
+ disposable.add(stack.onDidChange(() => this._onDidChangeEditorNavigationStack.fire()));
294
+ stacksForGroup.set(editor, { stack, disposable });
295
+ }
296
+ return stack;
297
+ }
298
+ case 1 : {
299
+ let stack = this.editorGroupScopedNavigationStacks.get(group.id)?.stack;
300
+ if (!stack) {
301
+ const disposable = ( new DisposableStore());
302
+ stack = disposable.add(this.instantiationService.createInstance(EditorNavigationStacks, 1 ));
303
+ disposable.add(stack.onDidChange(() => this._onDidChangeEditorNavigationStack.fire()));
304
+ this.editorGroupScopedNavigationStacks.set(group.id, { stack, disposable });
305
+ }
306
+ return stack;
307
+ }
308
+ case 0 : {
309
+ if (!this.defaultScopedEditorNavigationStack) {
310
+ this.defaultScopedEditorNavigationStack = this._register(this.instantiationService.createInstance(EditorNavigationStacks, 0 ));
311
+ this._register(this.defaultScopedEditorNavigationStack.onDidChange(() => this._onDidChangeEditorNavigationStack.fire()));
312
+ }
313
+ return this.defaultScopedEditorNavigationStack;
314
+ }
315
+ }
316
+ }
317
+ goForward(filter) {
318
+ return this.getStack().goForward(filter);
319
+ }
320
+ goBack(filter) {
321
+ return this.getStack().goBack(filter);
322
+ }
323
+ goPrevious(filter) {
324
+ return this.getStack().goPrevious(filter);
325
+ }
326
+ goLast(filter) {
327
+ return this.getStack().goLast(filter);
328
+ }
329
+ handleActiveEditorChangeInNavigationStacks(group, editorPane) {
330
+ this.getStack(group, editorPane?.input).handleActiveEditorChange(editorPane);
331
+ }
332
+ handleActiveEditorSelectionChangeInNavigationStacks(group, editorPane, event) {
333
+ this.getStack(group, editorPane.input).handleActiveEditorSelectionChange(editorPane, event);
334
+ }
335
+ handleEditorCloseEventInHistory(e) {
336
+ const editors = this.editorScopedNavigationStacks.get(e.groupId);
337
+ if (editors) {
338
+ const editorStack = editors.get(e.editor);
339
+ if (editorStack) {
340
+ editorStack.disposable.dispose();
341
+ editors.delete(e.editor);
342
+ }
343
+ if (editors.size === 0) {
344
+ this.editorScopedNavigationStacks.delete(e.groupId);
345
+ }
346
+ }
347
+ }
348
+ handleEditorGroupRemoveInNavigationStacks(group) {
349
+ this.defaultScopedEditorNavigationStack?.remove(group.id);
350
+ const editorGroupStack = this.editorGroupScopedNavigationStacks.get(group.id);
351
+ if (editorGroupStack) {
352
+ editorGroupStack.disposable.dispose();
353
+ this.editorGroupScopedNavigationStacks.delete(group.id);
354
+ }
355
+ }
356
+ clearEditorNavigationStacks() {
357
+ this.withEachEditorNavigationStack(stack => stack.clear());
358
+ }
359
+ removeFromEditorNavigationStacks(arg1) {
360
+ this.withEachEditorNavigationStack(stack => stack.remove(arg1));
361
+ }
362
+ moveInEditorNavigationStacks(event) {
363
+ this.withEachEditorNavigationStack(stack => stack.move(event));
364
+ }
365
+ withEachEditorNavigationStack(fn) {
366
+ if (this.defaultScopedEditorNavigationStack) {
367
+ fn(this.defaultScopedEditorNavigationStack);
368
+ }
369
+ for (const [, entry] of this.editorGroupScopedNavigationStacks) {
370
+ fn(entry.stack);
371
+ }
372
+ for (const [, entries] of this.editorScopedNavigationStacks) {
373
+ for (const [, entry] of entries) {
374
+ fn(entry.stack);
375
+ }
376
+ }
377
+ }
378
+ disposeEditorNavigationStacks() {
379
+ this.defaultScopedEditorNavigationStack?.dispose();
380
+ this.defaultScopedEditorNavigationStack = undefined;
381
+ for (const [, stack] of this.editorGroupScopedNavigationStacks) {
382
+ stack.disposable.dispose();
383
+ }
384
+ this.editorGroupScopedNavigationStacks.clear();
385
+ for (const [, stacks] of this.editorScopedNavigationStacks) {
386
+ for (const [, stack] of stacks) {
387
+ stack.disposable.dispose();
388
+ }
389
+ }
390
+ this.editorScopedNavigationStacks.clear();
391
+ }
392
+ openNextRecentlyUsedEditor(groupId) {
393
+ const [stack, index] = this.ensureRecentlyUsedStack(index => index - 1, groupId);
394
+ return this.doNavigateInRecentlyUsedEditorsStack(stack[index], groupId);
395
+ }
396
+ openPreviouslyUsedEditor(groupId) {
397
+ const [stack, index] = this.ensureRecentlyUsedStack(index => index + 1, groupId);
398
+ return this.doNavigateInRecentlyUsedEditorsStack(stack[index], groupId);
399
+ }
400
+ async doNavigateInRecentlyUsedEditorsStack(editorIdentifier, groupId) {
401
+ if (editorIdentifier) {
402
+ const acrossGroups = typeof groupId !== 'number' || !this.editorGroupService.getGroup(groupId);
403
+ if (acrossGroups) {
404
+ this.navigatingInRecentlyUsedEditorsStack = true;
405
+ }
406
+ else {
407
+ this.navigatingInRecentlyUsedEditorsInGroupStack = true;
408
+ }
409
+ const group = this.editorGroupService.getGroup(editorIdentifier.groupId) ?? this.editorGroupService.activeGroup;
410
+ try {
411
+ await group.openEditor(editorIdentifier.editor);
412
+ }
413
+ finally {
414
+ if (acrossGroups) {
415
+ this.navigatingInRecentlyUsedEditorsStack = false;
416
+ }
417
+ else {
418
+ this.navigatingInRecentlyUsedEditorsInGroupStack = false;
419
+ }
420
+ }
421
+ }
422
+ }
423
+ ensureRecentlyUsedStack(indexModifier, groupId) {
424
+ let editors;
425
+ let index;
426
+ const group = typeof groupId === 'number' ? this.editorGroupService.getGroup(groupId) : undefined;
427
+ if (!group) {
428
+ editors = this.recentlyUsedEditorsStack || this.editorService.getEditors(0 );
429
+ index = this.recentlyUsedEditorsStackIndex;
430
+ }
431
+ else {
432
+ editors = this.recentlyUsedEditorsInGroupStack || ( group.getEditors(0 ).map(editor => ({ groupId: group.id, editor })));
433
+ index = this.recentlyUsedEditorsInGroupStackIndex;
434
+ }
435
+ let newIndex = indexModifier(index);
436
+ if (newIndex < 0) {
437
+ newIndex = 0;
438
+ }
439
+ else if (newIndex > editors.length - 1) {
440
+ newIndex = editors.length - 1;
441
+ }
442
+ if (!group) {
443
+ this.recentlyUsedEditorsStack = editors;
444
+ this.recentlyUsedEditorsStackIndex = newIndex;
445
+ }
446
+ else {
447
+ this.recentlyUsedEditorsInGroupStack = editors;
448
+ this.recentlyUsedEditorsInGroupStackIndex = newIndex;
449
+ }
450
+ return [editors, newIndex];
451
+ }
452
+ handleEditorEventInRecentEditorsStack() {
453
+ if (!this.navigatingInRecentlyUsedEditorsStack) {
454
+ this.recentlyUsedEditorsStack = undefined;
455
+ this.recentlyUsedEditorsStackIndex = 0;
456
+ }
457
+ if (!this.navigatingInRecentlyUsedEditorsInGroupStack) {
458
+ this.recentlyUsedEditorsInGroupStack = undefined;
459
+ this.recentlyUsedEditorsInGroupStackIndex = 0;
460
+ }
461
+ }
462
+ static { this.MAX_RECENTLY_CLOSED_EDITORS = 20; }
463
+ handleEditorCloseEventInReopen(event) {
464
+ if (this.ignoreEditorCloseEvent) {
465
+ return;
466
+ }
467
+ const { editor, context } = event;
468
+ if (context === EditorCloseContext.REPLACE || context === EditorCloseContext.MOVE) {
469
+ return;
470
+ }
471
+ const untypedEditor = editor.toUntyped();
472
+ if (!untypedEditor) {
473
+ return;
474
+ }
475
+ const associatedResources = [];
476
+ const editorResource = EditorResourceAccessor.getOriginalUri(editor, { supportSideBySide: SideBySideEditor.BOTH });
477
+ if (URI.isUri(editorResource)) {
478
+ associatedResources.push(editorResource);
479
+ }
480
+ else if (editorResource) {
481
+ associatedResources.push(...coalesce([editorResource.primary, editorResource.secondary]));
482
+ }
483
+ this.removeFromRecentlyClosedEditors(editor);
484
+ this.recentlyClosedEditors.push({
485
+ editorId: editor.editorId,
486
+ editor: untypedEditor,
487
+ resource: EditorResourceAccessor.getOriginalUri(editor),
488
+ associatedResources,
489
+ index: event.index,
490
+ sticky: event.sticky
491
+ });
492
+ if (this.recentlyClosedEditors.length > HistoryService_1.MAX_RECENTLY_CLOSED_EDITORS) {
493
+ this.recentlyClosedEditors.shift();
494
+ }
495
+ this.canReopenClosedEditorContextKey.set(true);
496
+ }
497
+ async reopenLastClosedEditor() {
498
+ const lastClosedEditor = this.recentlyClosedEditors.pop();
499
+ let reopenClosedEditorPromise = undefined;
500
+ if (lastClosedEditor) {
501
+ reopenClosedEditorPromise = this.doReopenLastClosedEditor(lastClosedEditor);
502
+ }
503
+ this.canReopenClosedEditorContextKey.set(this.recentlyClosedEditors.length > 0);
504
+ return reopenClosedEditorPromise;
505
+ }
506
+ async doReopenLastClosedEditor(lastClosedEditor) {
507
+ const options = { pinned: true, sticky: lastClosedEditor.sticky, index: lastClosedEditor.index, ignoreError: true };
508
+ if ((lastClosedEditor.sticky && !this.editorGroupService.activeGroup.isSticky(lastClosedEditor.index)) ||
509
+ (!lastClosedEditor.sticky && this.editorGroupService.activeGroup.isSticky(lastClosedEditor.index))) {
510
+ options.index = undefined;
511
+ }
512
+ let editorPane = undefined;
513
+ if (!this.editorGroupService.activeGroup.contains(lastClosedEditor.editor)) {
514
+ this.ignoreEditorCloseEvent = true;
515
+ try {
516
+ editorPane = await this.editorService.openEditor({
517
+ ...lastClosedEditor.editor,
518
+ options: {
519
+ ...lastClosedEditor.editor.options,
520
+ ...options
521
+ }
522
+ });
523
+ }
524
+ finally {
525
+ this.ignoreEditorCloseEvent = false;
526
+ }
527
+ }
528
+ if (!editorPane) {
529
+ remove(this.recentlyClosedEditors, lastClosedEditor);
530
+ this.reopenLastClosedEditor();
531
+ }
532
+ }
533
+ removeFromRecentlyClosedEditors(arg1) {
534
+ this.recentlyClosedEditors = this.recentlyClosedEditors.filter(recentlyClosedEditor => {
535
+ if (isEditorInput(arg1) && recentlyClosedEditor.editorId !== arg1.editorId) {
536
+ return true;
537
+ }
538
+ if (recentlyClosedEditor.resource && this.editorHelper.matchesFile(recentlyClosedEditor.resource, arg1)) {
539
+ return false;
540
+ }
541
+ if (( recentlyClosedEditor.associatedResources.some(
542
+ associatedResource => this.editorHelper.matchesFile(associatedResource, arg1)
543
+ ))) {
544
+ return false;
545
+ }
546
+ return true;
547
+ });
548
+ this.canReopenClosedEditorContextKey.set(this.recentlyClosedEditors.length > 0);
549
+ }
550
+ static { this.MAX_HISTORY_ITEMS = 200; }
551
+ static { this.HISTORY_STORAGE_KEY = 'history.entries'; }
552
+ handleActiveEditorChangeInHistory(editorPane) {
553
+ const editor = editorPane?.input;
554
+ if (!editor || editor.isDisposed() || !this.includeInHistory(editor)) {
555
+ return;
556
+ }
557
+ this.removeFromHistory(editor);
558
+ this.addToHistory(editor);
559
+ }
560
+ addToHistory(editor, insertFirst = true) {
561
+ this.ensureHistoryLoaded(this.history);
562
+ const historyInput = this.editorHelper.preferResourceEditorInput(editor);
563
+ if (!historyInput) {
564
+ return;
565
+ }
566
+ if (insertFirst) {
567
+ this.history.unshift(historyInput);
568
+ }
569
+ else {
570
+ this.history.push(historyInput);
571
+ }
572
+ if (this.history.length > HistoryService_1.MAX_HISTORY_ITEMS) {
573
+ this.editorHelper.clearOnEditorDispose(this.history.pop(), this.editorHistoryListeners);
574
+ }
575
+ if (isEditorInput(historyInput)) {
576
+ this.editorHelper.onEditorDispose(historyInput, () => this.updateHistoryOnEditorDispose(historyInput), this.editorHistoryListeners);
577
+ }
578
+ }
579
+ updateHistoryOnEditorDispose(editor) {
580
+ if (!isSideBySideEditorInput(editor)) {
581
+ this.removeFromHistory(editor);
582
+ }
583
+ else {
584
+ const resourceInputs = [];
585
+ const sideInputs = editor.primary.matches(editor.secondary) ? [editor.primary] : [editor.primary, editor.secondary];
586
+ for (const sideInput of sideInputs) {
587
+ const candidateResourceInput = this.editorHelper.preferResourceEditorInput(sideInput);
588
+ if (isResourceEditorInput(candidateResourceInput)) {
589
+ resourceInputs.push(candidateResourceInput);
590
+ }
591
+ }
592
+ this.replaceInHistory(editor, ...resourceInputs);
593
+ }
594
+ }
595
+ includeInHistory(editor) {
596
+ if (isEditorInput(editor)) {
597
+ return true;
598
+ }
599
+ return !this.resourceExcludeMatcher.value.matches(editor.resource);
600
+ }
601
+ removeExcludedFromHistory() {
602
+ this.ensureHistoryLoaded(this.history);
603
+ this.history = this.history.filter(entry => {
604
+ const include = this.includeInHistory(entry);
605
+ if (!include) {
606
+ this.editorHelper.clearOnEditorDispose(entry, this.editorHistoryListeners);
607
+ }
608
+ return include;
609
+ });
610
+ }
611
+ moveInHistory(event) {
612
+ if (event.isOperation(2 )) {
613
+ const removed = this.removeFromHistory(event);
614
+ if (removed) {
615
+ this.addToHistory({ resource: event.target.resource });
616
+ }
617
+ }
618
+ }
619
+ removeFromHistory(arg1) {
620
+ let removed = false;
621
+ this.ensureHistoryLoaded(this.history);
622
+ this.history = this.history.filter(entry => {
623
+ const matches = this.editorHelper.matchesEditor(arg1, entry);
624
+ if (matches) {
625
+ this.editorHelper.clearOnEditorDispose(arg1, this.editorHistoryListeners);
626
+ removed = true;
627
+ }
628
+ return !matches;
629
+ });
630
+ return removed;
631
+ }
632
+ replaceInHistory(editor, ...replacements) {
633
+ this.ensureHistoryLoaded(this.history);
634
+ let replaced = false;
635
+ const newHistory = [];
636
+ for (const entry of this.history) {
637
+ if (this.editorHelper.matchesEditor(editor, entry)) {
638
+ this.editorHelper.clearOnEditorDispose(editor, this.editorHistoryListeners);
639
+ if (!replaced) {
640
+ newHistory.push(...replacements);
641
+ replaced = true;
642
+ }
643
+ }
644
+ else if (!( replacements.some(replacement => this.editorHelper.matchesEditor(replacement, entry)))) {
645
+ newHistory.push(entry);
646
+ }
647
+ }
648
+ if (!replaced) {
649
+ newHistory.push(...replacements);
650
+ }
651
+ this.history = newHistory;
652
+ }
653
+ clearRecentlyOpened() {
654
+ this.history = [];
655
+ for (const [, disposable] of this.editorHistoryListeners) {
656
+ dispose(disposable);
657
+ }
658
+ this.editorHistoryListeners.clear();
659
+ }
660
+ getHistory() {
661
+ this.ensureHistoryLoaded(this.history);
662
+ return this.history;
663
+ }
664
+ ensureHistoryLoaded(history) {
665
+ if (!this.history) {
666
+ this.history = [];
667
+ if (this.editorGroupService.isReady) {
668
+ this.loadHistory();
669
+ }
670
+ else {
671
+ (async () => {
672
+ await this.editorGroupService.whenReady;
673
+ this.loadHistory();
674
+ })();
675
+ }
676
+ }
677
+ }
678
+ loadHistory() {
679
+ this.history = [];
680
+ const storedEditorHistory = this.loadHistoryFromStorage();
681
+ const openedEditorsLru = [...this.editorService.getEditors(0 )].reverse();
682
+ const handledEditors = ( new Set());
683
+ for (const { editor } of openedEditorsLru) {
684
+ if (!this.includeInHistory(editor)) {
685
+ continue;
686
+ }
687
+ this.addToHistory(editor);
688
+ if (editor.resource) {
689
+ handledEditors.add(`${( editor.resource.toString())}/${editor.editorId}`);
690
+ }
691
+ }
692
+ for (const editor of storedEditorHistory) {
693
+ if (!( handledEditors.has(`${( editor.resource.toString())}/${editor.options?.override}`))) {
694
+ this.addToHistory(editor, false );
695
+ }
696
+ }
697
+ }
698
+ loadHistoryFromStorage() {
699
+ const entries = [];
700
+ const entriesRaw = this.storageService.get(HistoryService_1.HISTORY_STORAGE_KEY, 1 );
701
+ if (entriesRaw) {
702
+ try {
703
+ const entriesParsed = JSON.parse(entriesRaw);
704
+ for (const entryParsed of entriesParsed) {
705
+ if (!entryParsed.editor || !entryParsed.editor.resource) {
706
+ continue;
707
+ }
708
+ try {
709
+ entries.push({
710
+ ...entryParsed.editor,
711
+ resource: typeof entryParsed.editor.resource === 'string' ?
712
+ (
713
+ URI.parse(entryParsed.editor.resource)) :
714
+ ( URI.from(entryParsed.editor.resource))
715
+ });
716
+ }
717
+ catch (error) {
718
+ onUnexpectedError(error);
719
+ }
720
+ }
721
+ }
722
+ catch (error) {
723
+ onUnexpectedError(error);
724
+ }
725
+ }
726
+ return entries;
727
+ }
728
+ saveState() {
729
+ if (!this.history) {
730
+ return;
731
+ }
732
+ const entries = [];
733
+ for (const editor of this.history) {
734
+ if (isEditorInput(editor) || !isResourceEditorInput(editor)) {
735
+ continue;
736
+ }
737
+ entries.push({
738
+ editor: {
739
+ ...editor,
740
+ resource: ( editor.resource.toString())
741
+ }
742
+ });
743
+ }
744
+ this.storageService.store(HistoryService_1.HISTORY_STORAGE_KEY, JSON.stringify(entries), 1 , 1 );
745
+ }
746
+ getLastActiveWorkspaceRoot(schemeFilter, authorityFilter) {
747
+ const folders = this.contextService.getWorkspace().folders;
748
+ if (folders.length === 0) {
749
+ return undefined;
750
+ }
751
+ if (folders.length === 1) {
752
+ const resource = folders[0].uri;
753
+ if ((!schemeFilter || resource.scheme === schemeFilter) && (!authorityFilter || resource.authority === authorityFilter)) {
754
+ return resource;
755
+ }
756
+ return undefined;
757
+ }
758
+ for (const input of this.getHistory()) {
759
+ if (isEditorInput(input)) {
760
+ continue;
761
+ }
762
+ if (schemeFilter && input.resource.scheme !== schemeFilter) {
763
+ continue;
764
+ }
765
+ if (authorityFilter && input.resource.authority !== authorityFilter) {
766
+ continue;
767
+ }
768
+ const resourceWorkspace = this.contextService.getWorkspaceFolder(input.resource);
769
+ if (resourceWorkspace) {
770
+ return resourceWorkspace.uri;
771
+ }
772
+ }
773
+ for (const folder of folders) {
774
+ const resource = folder.uri;
775
+ if ((!schemeFilter || resource.scheme === schemeFilter) && (!authorityFilter || resource.authority === authorityFilter)) {
776
+ return resource;
777
+ }
778
+ }
779
+ return undefined;
780
+ }
781
+ getLastActiveFile(filterByScheme, filterByAuthority) {
782
+ for (const input of this.getHistory()) {
783
+ let resource;
784
+ if (isEditorInput(input)) {
785
+ resource = EditorResourceAccessor.getOriginalUri(input, { filterByScheme });
786
+ }
787
+ else {
788
+ resource = input.resource;
789
+ }
790
+ if (resource && resource.scheme === filterByScheme && (!filterByAuthority || resource.authority === filterByAuthority)) {
791
+ return resource;
792
+ }
793
+ }
794
+ return undefined;
795
+ }
796
+ dispose() {
797
+ super.dispose();
798
+ for (const [, stack] of this.editorGroupScopedNavigationStacks) {
799
+ stack.disposable.dispose();
800
+ }
801
+ for (const [, editors] of this.editorScopedNavigationStacks) {
802
+ for (const [, stack] of editors) {
803
+ stack.disposable.dispose();
804
+ }
805
+ }
806
+ }
807
+ };
808
+ HistoryService = HistoryService_1 = ( __decorate([
809
+ ( __param(0, IEditorService)),
810
+ ( __param(1, IEditorGroupsService)),
811
+ ( __param(2, IWorkspaceContextService)),
812
+ ( __param(3, IStorageService)),
813
+ ( __param(4, IConfigurationService)),
814
+ ( __param(5, IFileService)),
815
+ ( __param(6, IWorkspacesService)),
816
+ ( __param(7, IInstantiationService)),
817
+ ( __param(8, IWorkbenchLayoutService)),
818
+ ( __param(9, IContextKeyService))
819
+ ], HistoryService));
820
+ ( registerSingleton(IHistoryService, HistoryService, 0 ));
821
+ class EditorSelectionState {
822
+ constructor(editorIdentifier, selection, reason) {
823
+ this.editorIdentifier = editorIdentifier;
824
+ this.selection = selection;
825
+ this.reason = reason;
826
+ }
827
+ justifiesNewNavigationEntry(other) {
828
+ if (this.editorIdentifier.groupId !== other.editorIdentifier.groupId) {
829
+ return true;
830
+ }
831
+ if (!this.editorIdentifier.editor.matches(other.editorIdentifier.editor)) {
832
+ return true;
833
+ }
834
+ if (!this.selection || !other.selection) {
835
+ return true;
836
+ }
837
+ const result = this.selection.compare(other.selection);
838
+ if (result === 2 && ((other.reason === 4 || other.reason === 5) )) {
839
+ return true;
840
+ }
841
+ return result === 3 ;
842
+ }
843
+ }
844
+ let EditorNavigationStacks = class EditorNavigationStacks extends Disposable {
845
+ constructor(scope, instantiationService) {
846
+ super();
847
+ this.scope = scope;
848
+ this.instantiationService = instantiationService;
849
+ this.selectionsStack = this._register(this.instantiationService.createInstance(EditorNavigationStack, 0 , this.scope));
850
+ this.editsStack = this._register(this.instantiationService.createInstance(EditorNavigationStack, 1 , this.scope));
851
+ this.navigationsStack = this._register(this.instantiationService.createInstance(EditorNavigationStack, 2 , this.scope));
852
+ this.stacks = [
853
+ this.selectionsStack,
854
+ this.editsStack,
855
+ this.navigationsStack
856
+ ];
857
+ this.onDidChange = Event.any(this.selectionsStack.onDidChange, this.editsStack.onDidChange, this.navigationsStack.onDidChange);
858
+ }
859
+ canGoForward(filter) {
860
+ return this.getStack(filter).canGoForward();
861
+ }
862
+ goForward(filter) {
863
+ return this.getStack(filter).goForward();
864
+ }
865
+ canGoBack(filter) {
866
+ return this.getStack(filter).canGoBack();
867
+ }
868
+ goBack(filter) {
869
+ return this.getStack(filter).goBack();
870
+ }
871
+ goPrevious(filter) {
872
+ return this.getStack(filter).goPrevious();
873
+ }
874
+ canGoLast(filter) {
875
+ return this.getStack(filter).canGoLast();
876
+ }
877
+ goLast(filter) {
878
+ return this.getStack(filter).goLast();
879
+ }
880
+ getStack(filter = 0 ) {
881
+ switch (filter) {
882
+ case 0 : return this.selectionsStack;
883
+ case 1 : return this.editsStack;
884
+ case 2 : return this.navigationsStack;
885
+ }
886
+ }
887
+ handleActiveEditorChange(editorPane) {
888
+ this.selectionsStack.notifyNavigation(editorPane);
889
+ }
890
+ handleActiveEditorSelectionChange(editorPane, event) {
891
+ const previous = this.selectionsStack.current;
892
+ this.selectionsStack.notifyNavigation(editorPane, event);
893
+ if (event.reason === 3 ) {
894
+ this.editsStack.notifyNavigation(editorPane, event);
895
+ }
896
+ else if (((event.reason === 4 || event.reason === 5) ) &&
897
+ !this.selectionsStack.isNavigating()) {
898
+ if (event.reason === 5 && !this.navigationsStack.isNavigating()) {
899
+ if (previous) {
900
+ this.navigationsStack.addOrReplace(previous.groupId, previous.editor, previous.selection);
901
+ }
902
+ }
903
+ this.navigationsStack.notifyNavigation(editorPane, event);
904
+ }
905
+ }
906
+ clear() {
907
+ for (const stack of this.stacks) {
908
+ stack.clear();
909
+ }
910
+ }
911
+ remove(arg1) {
912
+ for (const stack of this.stacks) {
913
+ stack.remove(arg1);
914
+ }
915
+ }
916
+ move(event) {
917
+ for (const stack of this.stacks) {
918
+ stack.move(event);
919
+ }
920
+ }
921
+ };
922
+ EditorNavigationStacks = ( __decorate([
923
+ ( __param(1, IInstantiationService))
924
+ ], EditorNavigationStacks));
925
+ class NoOpEditorNavigationStacks {
926
+ constructor() {
927
+ this.onDidChange = Event.None;
928
+ }
929
+ canGoForward() { return false; }
930
+ async goForward() { }
931
+ canGoBack() { return false; }
932
+ async goBack() { }
933
+ async goPrevious() { }
934
+ canGoLast() { return false; }
935
+ async goLast() { }
936
+ handleActiveEditorChange() { }
937
+ handleActiveEditorSelectionChange() { }
938
+ clear() { }
939
+ remove() { }
940
+ move() { }
941
+ dispose() { }
942
+ }
943
+ let EditorNavigationStack = class EditorNavigationStack extends Disposable {
944
+ static { EditorNavigationStack_1 = this; }
945
+ static { this.MAX_STACK_SIZE = 50; }
946
+ get current() {
947
+ return this.stack[this.index];
948
+ }
949
+ set current(entry) {
950
+ if (entry) {
951
+ this.stack[this.index] = entry;
952
+ }
953
+ }
954
+ constructor(filter, scope, instantiationService, editorService, editorGroupService, logService) {
955
+ super();
956
+ this.filter = filter;
957
+ this.scope = scope;
958
+ this.instantiationService = instantiationService;
959
+ this.editorService = editorService;
960
+ this.editorGroupService = editorGroupService;
961
+ this.logService = logService;
962
+ this._onDidChange = this._register(( new Emitter()));
963
+ this.onDidChange = this._onDidChange.event;
964
+ this.mapEditorToDisposable = ( new Map());
965
+ this.mapGroupToDisposable = ( new Map());
966
+ this.editorHelper = this.instantiationService.createInstance(EditorHelper);
967
+ this.stack = [];
968
+ this.index = -1;
969
+ this.previousIndex = -1;
970
+ this.navigating = false;
971
+ this.currentSelectionState = undefined;
972
+ this.registerListeners();
973
+ }
974
+ registerListeners() {
975
+ this._register(this.onDidChange(() => this.traceStack()));
976
+ this._register(this.logService.onDidChangeLogLevel(() => this.traceStack()));
977
+ }
978
+ traceStack() {
979
+ if (this.logService.getLevel() !== LogLevel.Trace) {
980
+ return;
981
+ }
982
+ const entryLabels = [];
983
+ for (const entry of this.stack) {
984
+ if (typeof entry.selection?.log === 'function') {
985
+ entryLabels.push(`- group: ${entry.groupId}, editor: ${entry.editor.resource?.toString()}, selection: ${entry.selection.log()}`);
986
+ }
987
+ else {
988
+ entryLabels.push(`- group: ${entry.groupId}, editor: ${entry.editor.resource?.toString()}, selection: <none>`);
989
+ }
990
+ }
991
+ if (entryLabels.length === 0) {
992
+ this.trace(`index: ${this.index}, navigating: ${this.isNavigating()}: <empty>`);
993
+ }
994
+ else {
995
+ this.trace(`index: ${this.index}, navigating: ${this.isNavigating()}
996
+ ${entryLabels.join('\n')}
997
+ `);
998
+ }
999
+ }
1000
+ trace(msg, editor = null, event) {
1001
+ if (this.logService.getLevel() !== LogLevel.Trace) {
1002
+ return;
1003
+ }
1004
+ let filterLabel;
1005
+ switch (this.filter) {
1006
+ case 0 :
1007
+ filterLabel = 'global';
1008
+ break;
1009
+ case 1 :
1010
+ filterLabel = 'edits';
1011
+ break;
1012
+ case 2 :
1013
+ filterLabel = 'navigation';
1014
+ break;
1015
+ }
1016
+ let scopeLabel;
1017
+ switch (this.scope) {
1018
+ case 0 :
1019
+ scopeLabel = 'default';
1020
+ break;
1021
+ case 1 :
1022
+ scopeLabel = 'editorGroup';
1023
+ break;
1024
+ case 2 :
1025
+ scopeLabel = 'editor';
1026
+ break;
1027
+ }
1028
+ if (editor !== null) {
1029
+ this.logService.trace(`[History stack ${filterLabel}-${scopeLabel}]: ${msg} (editor: ${editor?.resource?.toString()}, event: ${this.traceEvent(event)})`);
1030
+ }
1031
+ else {
1032
+ this.logService.trace(`[History stack ${filterLabel}-${scopeLabel}]: ${msg}`);
1033
+ }
1034
+ }
1035
+ traceEvent(event) {
1036
+ if (!event) {
1037
+ return '<none>';
1038
+ }
1039
+ switch (event.reason) {
1040
+ case 3 : return 'edit';
1041
+ case 4 : return 'navigation';
1042
+ case 5 : return 'jump';
1043
+ case 1 : return 'programmatic';
1044
+ case 2 : return 'user';
1045
+ }
1046
+ }
1047
+ registerGroupListeners(groupId) {
1048
+ if (!( this.mapGroupToDisposable.has(groupId))) {
1049
+ const group = this.editorGroupService.getGroup(groupId);
1050
+ if (group) {
1051
+ this.mapGroupToDisposable.set(groupId, group.onWillMoveEditor(e => this.onWillMoveEditor(e)));
1052
+ }
1053
+ }
1054
+ }
1055
+ onWillMoveEditor(e) {
1056
+ this.trace('onWillMoveEditor()', e.editor);
1057
+ if (this.scope === 1 ) {
1058
+ return;
1059
+ }
1060
+ for (const entry of this.stack) {
1061
+ if (entry.groupId !== e.groupId) {
1062
+ continue;
1063
+ }
1064
+ if (!this.editorHelper.matchesEditor(e.editor, entry.editor)) {
1065
+ continue;
1066
+ }
1067
+ entry.groupId = e.target;
1068
+ }
1069
+ }
1070
+ notifyNavigation(editorPane, event) {
1071
+ this.trace('notifyNavigation()', editorPane?.input, event);
1072
+ const isSelectionAwareEditorPane = isEditorPaneWithSelection(editorPane);
1073
+ const hasValidEditor = editorPane?.group && editorPane.input && !editorPane.input.isDisposed();
1074
+ if (this.navigating) {
1075
+ this.trace(`notifyNavigation() ignoring (navigating)`, editorPane?.input, event);
1076
+ if (isSelectionAwareEditorPane && hasValidEditor) {
1077
+ this.trace('notifyNavigation() updating current selection state', editorPane?.input, event);
1078
+ this.currentSelectionState = ( new EditorSelectionState(
1079
+ { groupId: editorPane.group.id, editor: editorPane.input },
1080
+ editorPane.getSelection(),
1081
+ event?.reason
1082
+ ));
1083
+ }
1084
+ else {
1085
+ this.trace('notifyNavigation() dropping current selection state', editorPane?.input, event);
1086
+ this.currentSelectionState = undefined;
1087
+ }
1088
+ }
1089
+ else {
1090
+ this.trace(`notifyNavigation() not ignoring`, editorPane?.input, event);
1091
+ if (isSelectionAwareEditorPane && hasValidEditor) {
1092
+ this.onSelectionAwareEditorNavigation(editorPane.group.id, editorPane.input, editorPane.getSelection(), event);
1093
+ }
1094
+ else {
1095
+ this.currentSelectionState = undefined;
1096
+ if (hasValidEditor) {
1097
+ this.onNonSelectionAwareEditorNavigation(editorPane.group.id, editorPane.input);
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+ onSelectionAwareEditorNavigation(groupId, editor, selection, event) {
1103
+ if (this.current?.groupId === groupId && !selection && this.editorHelper.matchesEditor(this.current.editor, editor)) {
1104
+ return;
1105
+ }
1106
+ this.trace('onSelectionAwareEditorNavigation()', editor, event);
1107
+ const stateCandidate = ( new EditorSelectionState({ groupId, editor }, selection, event?.reason));
1108
+ if (!this.currentSelectionState || this.currentSelectionState.justifiesNewNavigationEntry(stateCandidate)) {
1109
+ this.doAdd(groupId, editor, stateCandidate.selection);
1110
+ }
1111
+ else {
1112
+ this.doReplace(groupId, editor, stateCandidate.selection);
1113
+ }
1114
+ this.currentSelectionState = stateCandidate;
1115
+ }
1116
+ onNonSelectionAwareEditorNavigation(groupId, editor) {
1117
+ if (this.current?.groupId === groupId && this.editorHelper.matchesEditor(this.current.editor, editor)) {
1118
+ return;
1119
+ }
1120
+ this.trace('onNonSelectionAwareEditorNavigation()', editor);
1121
+ this.doAdd(groupId, editor);
1122
+ }
1123
+ doAdd(groupId, editor, selection) {
1124
+ if (!this.navigating) {
1125
+ this.addOrReplace(groupId, editor, selection);
1126
+ }
1127
+ }
1128
+ doReplace(groupId, editor, selection) {
1129
+ if (!this.navigating) {
1130
+ this.addOrReplace(groupId, editor, selection, true );
1131
+ }
1132
+ }
1133
+ addOrReplace(groupId, editorCandidate, selection, forceReplace) {
1134
+ this.registerGroupListeners(groupId);
1135
+ let replace = false;
1136
+ if (this.current) {
1137
+ if (forceReplace) {
1138
+ replace = true;
1139
+ }
1140
+ else if (this.shouldReplaceStackEntry(this.current, { groupId, editor: editorCandidate, selection })) {
1141
+ replace = true;
1142
+ }
1143
+ }
1144
+ const editor = this.editorHelper.preferResourceEditorInput(editorCandidate);
1145
+ if (!editor) {
1146
+ return;
1147
+ }
1148
+ if (replace) {
1149
+ this.trace('replace()', editor);
1150
+ }
1151
+ else {
1152
+ this.trace('add()', editor);
1153
+ }
1154
+ const newStackEntry = { groupId, editor, selection };
1155
+ const removedEntries = [];
1156
+ if (replace) {
1157
+ if (this.current) {
1158
+ removedEntries.push(this.current);
1159
+ }
1160
+ this.current = newStackEntry;
1161
+ }
1162
+ else {
1163
+ if (this.stack.length > this.index + 1) {
1164
+ for (let i = this.index + 1; i < this.stack.length; i++) {
1165
+ removedEntries.push(this.stack[i]);
1166
+ }
1167
+ this.stack = this.stack.slice(0, this.index + 1);
1168
+ }
1169
+ this.stack.splice(this.index + 1, 0, newStackEntry);
1170
+ if (this.stack.length > EditorNavigationStack_1.MAX_STACK_SIZE) {
1171
+ removedEntries.push(this.stack.shift());
1172
+ if (this.previousIndex >= 0) {
1173
+ this.previousIndex--;
1174
+ }
1175
+ }
1176
+ else {
1177
+ this.setIndex(this.index + 1, true );
1178
+ }
1179
+ }
1180
+ for (const removedEntry of removedEntries) {
1181
+ this.editorHelper.clearOnEditorDispose(removedEntry.editor, this.mapEditorToDisposable);
1182
+ }
1183
+ if (isEditorInput(editor)) {
1184
+ this.editorHelper.onEditorDispose(editor, () => this.remove(editor), this.mapEditorToDisposable);
1185
+ }
1186
+ this._onDidChange.fire();
1187
+ }
1188
+ shouldReplaceStackEntry(entry, candidate) {
1189
+ if (entry.groupId !== candidate.groupId) {
1190
+ return false;
1191
+ }
1192
+ if (!this.editorHelper.matchesEditor(entry.editor, candidate.editor)) {
1193
+ return false;
1194
+ }
1195
+ if (!entry.selection) {
1196
+ return true;
1197
+ }
1198
+ if (!candidate.selection) {
1199
+ return false;
1200
+ }
1201
+ return entry.selection.compare(candidate.selection) === 1 ;
1202
+ }
1203
+ move(event) {
1204
+ if (event.isOperation(2 )) {
1205
+ for (const entry of this.stack) {
1206
+ if (this.editorHelper.matchesEditor(event, entry.editor)) {
1207
+ entry.editor = { resource: event.target.resource };
1208
+ }
1209
+ }
1210
+ }
1211
+ }
1212
+ remove(arg1) {
1213
+ this.stack = this.stack.filter(entry => {
1214
+ const matches = typeof arg1 === 'number' ? entry.groupId === arg1 : this.editorHelper.matchesEditor(arg1, entry.editor);
1215
+ if (matches) {
1216
+ this.editorHelper.clearOnEditorDispose(entry.editor, this.mapEditorToDisposable);
1217
+ }
1218
+ return !matches;
1219
+ });
1220
+ this.flatten();
1221
+ this.index = this.stack.length - 1;
1222
+ this.previousIndex = -1;
1223
+ if (typeof arg1 === 'number') {
1224
+ this.mapGroupToDisposable.get(arg1)?.dispose();
1225
+ this.mapGroupToDisposable.delete(arg1);
1226
+ }
1227
+ this._onDidChange.fire();
1228
+ }
1229
+ flatten() {
1230
+ const flattenedStack = [];
1231
+ let previousEntry = undefined;
1232
+ for (const entry of this.stack) {
1233
+ if (previousEntry && this.shouldReplaceStackEntry(entry, previousEntry)) {
1234
+ continue;
1235
+ }
1236
+ previousEntry = entry;
1237
+ flattenedStack.push(entry);
1238
+ }
1239
+ this.stack = flattenedStack;
1240
+ }
1241
+ clear() {
1242
+ this.index = -1;
1243
+ this.previousIndex = -1;
1244
+ this.stack.splice(0);
1245
+ for (const [, disposable] of this.mapEditorToDisposable) {
1246
+ dispose(disposable);
1247
+ }
1248
+ this.mapEditorToDisposable.clear();
1249
+ for (const [, disposable] of this.mapGroupToDisposable) {
1250
+ dispose(disposable);
1251
+ }
1252
+ this.mapGroupToDisposable.clear();
1253
+ }
1254
+ dispose() {
1255
+ super.dispose();
1256
+ this.clear();
1257
+ }
1258
+ canGoForward() {
1259
+ return this.stack.length > this.index + 1;
1260
+ }
1261
+ async goForward() {
1262
+ const navigated = await this.maybeGoCurrent();
1263
+ if (navigated) {
1264
+ return;
1265
+ }
1266
+ if (!this.canGoForward()) {
1267
+ return;
1268
+ }
1269
+ this.setIndex(this.index + 1);
1270
+ return this.navigate();
1271
+ }
1272
+ canGoBack() {
1273
+ return this.index > 0;
1274
+ }
1275
+ async goBack() {
1276
+ const navigated = await this.maybeGoCurrent();
1277
+ if (navigated) {
1278
+ return;
1279
+ }
1280
+ if (!this.canGoBack()) {
1281
+ return;
1282
+ }
1283
+ this.setIndex(this.index - 1);
1284
+ return this.navigate();
1285
+ }
1286
+ async goPrevious() {
1287
+ const navigated = await this.maybeGoCurrent();
1288
+ if (navigated) {
1289
+ return;
1290
+ }
1291
+ if (this.previousIndex === -1) {
1292
+ return this.goBack();
1293
+ }
1294
+ this.setIndex(this.previousIndex);
1295
+ return this.navigate();
1296
+ }
1297
+ canGoLast() {
1298
+ return this.stack.length > 0;
1299
+ }
1300
+ async goLast() {
1301
+ if (!this.canGoLast()) {
1302
+ return;
1303
+ }
1304
+ this.setIndex(this.stack.length - 1);
1305
+ return this.navigate();
1306
+ }
1307
+ async maybeGoCurrent() {
1308
+ if (this.filter === 0 ) {
1309
+ return false;
1310
+ }
1311
+ if (this.isCurrentSelectionActive()) {
1312
+ return false;
1313
+ }
1314
+ await this.navigate();
1315
+ return true;
1316
+ }
1317
+ isCurrentSelectionActive() {
1318
+ if (!this.current?.selection) {
1319
+ return false;
1320
+ }
1321
+ const pane = this.editorService.activeEditorPane;
1322
+ if (!isEditorPaneWithSelection(pane)) {
1323
+ return false;
1324
+ }
1325
+ if (pane.group?.id !== this.current.groupId) {
1326
+ return false;
1327
+ }
1328
+ if (!pane.input || !this.editorHelper.matchesEditor(pane.input, this.current.editor)) {
1329
+ return false;
1330
+ }
1331
+ const paneSelection = pane.getSelection();
1332
+ if (!paneSelection) {
1333
+ return false;
1334
+ }
1335
+ return paneSelection.compare(this.current.selection) === 1 ;
1336
+ }
1337
+ setIndex(newIndex, skipEvent) {
1338
+ this.previousIndex = this.index;
1339
+ this.index = newIndex;
1340
+ if (!skipEvent) {
1341
+ this._onDidChange.fire();
1342
+ }
1343
+ }
1344
+ async navigate() {
1345
+ this.navigating = true;
1346
+ try {
1347
+ if (this.current) {
1348
+ await this.doNavigate(this.current);
1349
+ }
1350
+ }
1351
+ finally {
1352
+ this.navigating = false;
1353
+ }
1354
+ }
1355
+ doNavigate(location) {
1356
+ let options = Object.create(null);
1357
+ if (location.selection) {
1358
+ options = location.selection.restore(options);
1359
+ }
1360
+ if (isEditorInput(location.editor)) {
1361
+ return this.editorService.openEditor(location.editor, options, location.groupId);
1362
+ }
1363
+ return this.editorService.openEditor({
1364
+ ...location.editor,
1365
+ options: {
1366
+ ...location.editor.options,
1367
+ ...options
1368
+ }
1369
+ }, location.groupId);
1370
+ }
1371
+ isNavigating() {
1372
+ return this.navigating;
1373
+ }
1374
+ };
1375
+ EditorNavigationStack = EditorNavigationStack_1 = ( __decorate([
1376
+ ( __param(2, IInstantiationService)),
1377
+ ( __param(3, IEditorService)),
1378
+ ( __param(4, IEditorGroupsService)),
1379
+ ( __param(5, ILogService))
1380
+ ], EditorNavigationStack));
1381
+ let EditorHelper = class EditorHelper {
1382
+ constructor(uriIdentityService, lifecycleService, fileService, pathService) {
1383
+ this.uriIdentityService = uriIdentityService;
1384
+ this.lifecycleService = lifecycleService;
1385
+ this.fileService = fileService;
1386
+ this.pathService = pathService;
1387
+ }
1388
+ preferResourceEditorInput(editor) {
1389
+ const resource = EditorResourceAccessor.getOriginalUri(editor);
1390
+ const hasValidResourceEditorInputScheme = resource?.scheme === Schemas.file ||
1391
+ resource?.scheme === Schemas.vscodeRemote ||
1392
+ resource?.scheme === Schemas.vscodeUserData ||
1393
+ resource?.scheme === this.pathService.defaultUriScheme;
1394
+ if (hasValidResourceEditorInputScheme) {
1395
+ if (isEditorInput(editor)) {
1396
+ const untypedInput = editor.toUntyped();
1397
+ if (isResourceEditorInput(untypedInput)) {
1398
+ return untypedInput;
1399
+ }
1400
+ }
1401
+ return editor;
1402
+ }
1403
+ else {
1404
+ return isEditorInput(editor) ? editor : undefined;
1405
+ }
1406
+ }
1407
+ matchesEditor(arg1, inputB) {
1408
+ if (arg1 instanceof FileChangesEvent || arg1 instanceof FileOperationEvent) {
1409
+ if (isEditorInput(inputB)) {
1410
+ return false;
1411
+ }
1412
+ if (arg1 instanceof FileChangesEvent) {
1413
+ return arg1.contains(inputB.resource, 2 );
1414
+ }
1415
+ return this.matchesFile(inputB.resource, arg1);
1416
+ }
1417
+ if (isEditorInput(arg1)) {
1418
+ if (isEditorInput(inputB)) {
1419
+ return arg1.matches(inputB);
1420
+ }
1421
+ return this.matchesFile(inputB.resource, arg1);
1422
+ }
1423
+ if (isEditorInput(inputB)) {
1424
+ return this.matchesFile(arg1.resource, inputB);
1425
+ }
1426
+ return arg1 && inputB && this.uriIdentityService.extUri.isEqual(arg1.resource, inputB.resource);
1427
+ }
1428
+ matchesFile(resource, arg2) {
1429
+ if (arg2 instanceof FileChangesEvent) {
1430
+ return arg2.contains(resource, 2 );
1431
+ }
1432
+ if (arg2 instanceof FileOperationEvent) {
1433
+ return this.uriIdentityService.extUri.isEqualOrParent(resource, arg2.resource);
1434
+ }
1435
+ if (isEditorInput(arg2)) {
1436
+ const inputResource = arg2.resource;
1437
+ if (!inputResource) {
1438
+ return false;
1439
+ }
1440
+ if (this.lifecycleService.phase >= 3 && !this.fileService.hasProvider(inputResource)) {
1441
+ return false;
1442
+ }
1443
+ return this.uriIdentityService.extUri.isEqual(inputResource, resource);
1444
+ }
1445
+ return this.uriIdentityService.extUri.isEqual(arg2?.resource, resource);
1446
+ }
1447
+ matchesEditorIdentifier(identifier, editorPane) {
1448
+ if (!editorPane?.group) {
1449
+ return false;
1450
+ }
1451
+ if (identifier.groupId !== editorPane.group.id) {
1452
+ return false;
1453
+ }
1454
+ return editorPane.input ? identifier.editor.matches(editorPane.input) : false;
1455
+ }
1456
+ onEditorDispose(editor, listener, mapEditorToDispose) {
1457
+ const toDispose = Event.once(editor.onWillDispose)(() => listener());
1458
+ let disposables = mapEditorToDispose.get(editor);
1459
+ if (!disposables) {
1460
+ disposables = ( new DisposableStore());
1461
+ mapEditorToDispose.set(editor, disposables);
1462
+ }
1463
+ disposables.add(toDispose);
1464
+ }
1465
+ clearOnEditorDispose(editor, mapEditorToDispose) {
1466
+ if (!isEditorInput(editor)) {
1467
+ return;
1468
+ }
1469
+ const disposables = mapEditorToDispose.get(editor);
1470
+ if (disposables) {
1471
+ dispose(disposables);
1472
+ mapEditorToDispose.delete(editor);
1473
+ }
1474
+ }
1475
+ };
1476
+ EditorHelper = ( __decorate([
1477
+ ( __param(0, IUriIdentityService)),
1478
+ ( __param(1, ILifecycleService)),
1479
+ ( __param(2, IFileService)),
1480
+ ( __param(3, IPathService))
1481
+ ], EditorHelper));
1482
+ export { EditorNavigationStack, HistoryService };