@codingame/monaco-vscode-scm-service-override 31.0.0 → 32.0.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.
@@ -1,173 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
-
6
- .monaco-editor .dirty-diff-glyph {
7
- margin-left: 5px;
8
- z-index: 5;
9
- }
10
-
11
- .monaco-editor .dirty-diff-glyph:before {
12
- position: absolute;
13
- content: '';
14
- height: 100%;
15
- width: 0;
16
- left: -2px;
17
- }
18
-
19
- .monaco-workbench.monaco-enable-motion .monaco-editor .dirty-diff-glyph:before {
20
- transition: width 80ms linear, left 80ms linear, transform 80ms linear;
21
- }
22
-
23
- /* Hide glyph decorations when inside the inline diff editor */
24
- .monaco-editor.modified-in-monaco-diff-editor .margin-view-overlays > div > .dirty-diff-glyph {
25
- display: none;
26
- }
27
-
28
- .monaco-editor .dirty-diff-added:not(.pattern) {
29
- border-left-style: solid;
30
- }
31
-
32
- .monaco-editor .dirty-diff-added.primary {
33
- border-left-color: var(--vscode-editorGutter-addedBackground);
34
- }
35
-
36
- .monaco-editor .dirty-diff-added.primary:before {
37
- background: var(--vscode-editorGutter-addedBackground);
38
- }
39
-
40
- .monaco-editor .dirty-diff-added.secondary {
41
- border-left-color: var(--vscode-editorGutter-addedSecondaryBackground);
42
- }
43
-
44
- .monaco-editor .dirty-diff-added.secondary:before {
45
- background: var(--vscode-editorGutter-addedSecondaryBackground);
46
- }
47
-
48
- .monaco-editor .dirty-diff-added.pattern {
49
- background-repeat: repeat-y;
50
- }
51
-
52
- .monaco-editor .dirty-diff-added.pattern:before {
53
- transform: translateX(3px);
54
- }
55
-
56
- .monaco-editor .dirty-diff-added.pattern.primary,
57
- .monaco-editor .dirty-diff-added.pattern.primary:before {
58
- background-image: linear-gradient(-45deg, var(--vscode-editorGutter-addedBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-addedBackground) 50%, var(--vscode-editorGutter-addedBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
59
- }
60
-
61
- .monaco-editor .dirty-diff-added.pattern.secondary,
62
- .monaco-editor .dirty-diff-added.pattern.secondary:before {
63
- background-image: linear-gradient(45deg, var(--vscode-editorGutter-addedSecondaryBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-addedSecondaryBackground) 50%, var(--vscode-editorGutter-addedSecondaryBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
64
- }
65
-
66
- .monaco-editor .dirty-diff-modified:not(.pattern) {
67
- border-left-style: solid;
68
- }
69
-
70
- .monaco-editor .dirty-diff-modified.primary {
71
- border-left-color: var(--vscode-editorGutter-modifiedBackground);
72
- }
73
-
74
- .monaco-editor .dirty-diff-modified.primary:before {
75
- background: var(--vscode-editorGutter-modifiedBackground);
76
- }
77
-
78
- .monaco-editor .dirty-diff-modified.secondary {
79
- border-left-color: var(--vscode-editorGutter-modifiedSecondaryBackground);
80
- }
81
-
82
- .monaco-editor .dirty-diff-modified.secondary:before {
83
- background: var(--vscode-editorGutter-modifiedSecondaryBackground);
84
- }
85
-
86
- .monaco-editor .dirty-diff-modified.pattern {
87
- background-repeat: repeat-y;
88
- }
89
-
90
- .monaco-editor .dirty-diff-modified.pattern:before {
91
- transform: translateX(3px);
92
- }
93
-
94
- .monaco-editor .dirty-diff-modified.pattern.primary,
95
- .monaco-editor .dirty-diff-modified.pattern.primary:before {
96
- background-image: linear-gradient(-45deg, var(--vscode-editorGutter-modifiedBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-modifiedBackground) 50%, var(--vscode-editorGutter-modifiedBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
97
- }
98
-
99
- .monaco-editor .dirty-diff-modified.pattern.secondary,
100
- .monaco-editor .dirty-diff-modified.pattern.secondary:before {
101
- background-image: linear-gradient(45deg, var(--vscode-editorGutter-modifiedSecondaryBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-modifiedSecondaryBackground) 50%, var(--vscode-editorGutter-modifiedSecondaryBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
102
- }
103
-
104
- .monaco-workbench.monaco-enable-motion .monaco-editor .dirty-diff-added,
105
- .monaco-workbench.monaco-enable-motion .monaco-editor .dirty-diff-modified,
106
- .monaco-workbench.monaco-enable-motion .monaco-editor .dirty-diff-deleted {
107
- transition: opacity 0.5s;
108
- }
109
-
110
- .monaco-editor .margin:hover .dirty-diff-added,
111
- .monaco-editor .margin:hover .dirty-diff-modified,
112
- .monaco-editor .margin:hover .dirty-diff-deleted {
113
- opacity: 1;
114
- }
115
-
116
- .monaco-editor .dirty-diff-deleted:after {
117
- content: '';
118
- position: absolute;
119
- bottom: -4px;
120
- box-sizing: border-box;
121
- width: 4px;
122
- height: 0;
123
- z-index: 9;
124
- border-top: 4px solid transparent;
125
- border-bottom: 4px solid transparent;
126
- pointer-events: none;
127
- }
128
-
129
- .monaco-editor .dirty-diff-deleted.primary:after {
130
- border-left: 4px solid var(--vscode-editorGutter-deletedBackground);
131
- }
132
-
133
- .monaco-editor .dirty-diff-deleted.secondary:after {
134
- border-left: 4px solid var(--vscode-editorGutter-deletedSecondaryBackground);
135
- }
136
-
137
- .monaco-workbench.monaco-enable-motion .monaco-editor .dirty-diff-deleted:after {
138
- transition: border-top-width 80ms linear, border-bottom-width 80ms linear, bottom 80ms linear, opacity 0.5s;
139
- }
140
-
141
- .monaco-editor .dirty-diff-deleted:before {
142
- background: var(--vscode-editorGutter-deletedBackground);
143
- margin-left: 3px;
144
- height: 0;
145
- bottom: 0;
146
- }
147
-
148
- .monaco-editor .dirty-diff-deleted.primary:before {
149
- background: var(--vscode-editorGutter-deletedBackground);
150
- }
151
-
152
- .monaco-editor .dirty-diff-deleted.secondary:before {
153
- background: var(--vscode-editorGutter-deletedSecondaryBackground);
154
- }
155
-
156
- .monaco-workbench.monaco-enable-motion .monaco-editor .dirty-diff-deleted:before {
157
- transition: height 80ms linear;
158
- }
159
-
160
- .dirty-diff .peekview-title .dropdown {
161
- margin-right: 10px;
162
- }
163
-
164
- .dirty-diff .peekview-title .dropdown.select-container {
165
- cursor: default;
166
- }
167
-
168
- .dirty-diff .peekview-title .dropdown .monaco-select-box {
169
- cursor: pointer;
170
- min-width: 100px;
171
- min-height: 18px;
172
- padding: 0px 23px 0px 8px;
173
- }
@@ -1,36 +0,0 @@
1
- import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
- import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
3
- import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
4
- import { IQuickDiffService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff.service";
5
- import { IQuickDiffModelService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/browser/quickDiffModel.service";
6
- import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
7
- import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
8
- import { RawContextKey } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey";
9
- import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
10
- export declare const quickDiffDecorationCount: RawContextKey<number>;
11
- export declare class QuickDiffWorkbenchController extends Disposable implements IWorkbenchContribution {
12
- private readonly editorService;
13
- private readonly configurationService;
14
- private readonly quickDiffModelService;
15
- private readonly quickDiffService;
16
- private readonly uriIdentityService;
17
- private enabled;
18
- private readonly quickDiffDecorationCount;
19
- private readonly activeEditor;
20
- private readonly quickDiffProviders;
21
- private readonly decorators;
22
- private viewState;
23
- private readonly transientDisposables;
24
- private readonly stylesheet;
25
- constructor(editorService: IEditorService, configurationService: IConfigurationService, quickDiffModelService: IQuickDiffModelService, quickDiffService: IQuickDiffService, uriIdentityService: IUriIdentityService, contextKeyService: IContextKeyService);
26
- private onDidChangeConfiguration;
27
- private onDidChangeDiffWidthConfiguration;
28
- private onDidChangeDiffVisibilityConfiguration;
29
- private setViewState;
30
- private enable;
31
- private disable;
32
- private onDidActiveEditorChange;
33
- private onDidChangeQuickDiffProviders;
34
- private onEditorsChanged;
35
- dispose(): void;
36
- }
@@ -1,430 +0,0 @@
1
-
2
- import { registerCss } from '@codingame/monaco-vscode-api/css';
3
- import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
4
- import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
5
- import * as dirtydiffDecorator from './media/dirtydiffDecorator.css';
6
- import { Disposable, DisposableStore, DisposableMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
- import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
8
- import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
9
- import { ModelDecorationOptions } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model/textModel';
10
- import { themeColorFromId } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService';
11
- import { isCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
12
- import { OverviewRulerLane, MinimapPosition } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
13
- import { createStyleSheet } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/domStylesheets';
14
- import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
15
- import { minimapGutterAddedBackground, overviewRulerAddedForeground, minimapGutterModifiedBackground, overviewRulerModifiedForeground, minimapGutterDeletedBackground, overviewRulerDeletedForeground, getChangeType, ChangeType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff';
16
- import { IQuickDiffService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/common/quickDiff.service';
17
- import { IQuickDiffModelService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/scm/browser/quickDiffModel.service';
18
- import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
19
- import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
20
- import { RawContextKey, ContextKeyTrueExpr, ContextKeyFalseExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
21
- import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
22
- import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
23
- import { registerAction2, Action2, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
24
- import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
25
- import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
26
-
27
- var QuickDiffDecorator_1;
28
- registerCss(dirtydiffDecorator);
29
- const quickDiffDecorationCount = ( new RawContextKey("quickDiffDecorationCount", 0));
30
- let QuickDiffDecorator = QuickDiffDecorator_1 = class QuickDiffDecorator extends Disposable {
31
- static createDecoration(className, tooltip, options) {
32
- const decorationOptions = {
33
- description: "dirty-diff-decoration",
34
- isWholeLine: options.isWholeLine
35
- };
36
- if (options.gutter) {
37
- decorationOptions.linesDecorationsClassName = `dirty-diff-glyph ${className}`;
38
- decorationOptions.linesDecorationsTooltip = tooltip;
39
- }
40
- if (options.overview.active) {
41
- decorationOptions.overviewRuler = {
42
- color: themeColorFromId(options.overview.color),
43
- position: OverviewRulerLane.Left
44
- };
45
- }
46
- if (options.minimap.active) {
47
- decorationOptions.minimap = {
48
- color: themeColorFromId(options.minimap.color),
49
- position: MinimapPosition.Gutter
50
- };
51
- }
52
- return ModelDecorationOptions.createDynamic(decorationOptions);
53
- }
54
- constructor(codeEditor, quickDiffModelRef, configurationService, quickDiffService) {
55
- super();
56
- this.codeEditor = codeEditor;
57
- this.quickDiffModelRef = quickDiffModelRef;
58
- this.configurationService = configurationService;
59
- this.quickDiffService = quickDiffService;
60
- const decorations = configurationService.getValue("scm.diffDecorations");
61
- const gutter = decorations === "all" || decorations === "gutter";
62
- const overview = decorations === "all" || decorations === "overview";
63
- const minimap = decorations === "all" || decorations === "minimap";
64
- const diffAdded = ( localize(12349, "Added lines"));
65
- const diffAddedOptions = {
66
- gutter,
67
- overview: {
68
- active: overview,
69
- color: overviewRulerAddedForeground
70
- },
71
- minimap: {
72
- active: minimap,
73
- color: minimapGutterAddedBackground
74
- },
75
- isWholeLine: true
76
- };
77
- this.addedOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added primary", diffAdded, diffAddedOptions);
78
- this.addedPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added primary pattern", diffAdded, diffAddedOptions);
79
- this.addedSecondaryOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added secondary", diffAdded, diffAddedOptions);
80
- this.addedSecondaryPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-added secondary pattern", diffAdded, diffAddedOptions);
81
- const diffModified = ( localize(12350, "Changed lines"));
82
- const diffModifiedOptions = {
83
- gutter,
84
- overview: {
85
- active: overview,
86
- color: overviewRulerModifiedForeground
87
- },
88
- minimap: {
89
- active: minimap,
90
- color: minimapGutterModifiedBackground
91
- },
92
- isWholeLine: true
93
- };
94
- this.modifiedOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified primary", diffModified, diffModifiedOptions);
95
- this.modifiedPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified primary pattern", diffModified, diffModifiedOptions);
96
- this.modifiedSecondaryOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified secondary", diffModified, diffModifiedOptions);
97
- this.modifiedSecondaryPatternOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-modified secondary pattern", diffModified, diffModifiedOptions);
98
- const diffDeleted = ( localize(12351, "Removed lines"));
99
- const diffDeletedOptions = {
100
- gutter,
101
- overview: {
102
- active: overview,
103
- color: overviewRulerDeletedForeground
104
- },
105
- minimap: {
106
- active: minimap,
107
- color: minimapGutterDeletedBackground
108
- },
109
- isWholeLine: false
110
- };
111
- this.deletedOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-deleted primary", diffDeleted, diffDeletedOptions);
112
- this.deletedSecondaryOptions = QuickDiffDecorator_1.createDecoration("dirty-diff-deleted secondary", diffDeleted, diffDeletedOptions);
113
- this._register(configurationService.onDidChangeConfiguration(e => {
114
- if (e.affectsConfiguration("scm.diffDecorationsGutterPattern")) {
115
- this.onDidChange();
116
- }
117
- }));
118
- this._register(
119
- Event.runAndSubscribe(this.quickDiffModelRef.object.onDidChange, () => this.onDidChange())
120
- );
121
- }
122
- onDidChange() {
123
- if (!this.codeEditor.hasModel()) {
124
- return;
125
- }
126
- const pattern = this.configurationService.getValue("scm.diffDecorationsGutterPattern");
127
- const primaryQuickDiff = this.quickDiffModelRef.object.quickDiffs.find(quickDiff => quickDiff.kind === "primary");
128
- const primaryQuickDiffChanges = this.quickDiffModelRef.object.changes.filter(change => change.providerId === primaryQuickDiff?.id);
129
- const decorations = [];
130
- for (const change of this.quickDiffModelRef.object.changes) {
131
- const quickDiff = this.quickDiffModelRef.object.quickDiffs.find(quickDiff => quickDiff.id === change.providerId);
132
- if (!quickDiff || !this.quickDiffService.isQuickDiffProviderVisible(quickDiff.id)) {
133
- continue;
134
- }
135
- if (quickDiff.kind !== "primary" && ( primaryQuickDiffChanges.some(c => c.change2.modified.intersectsOrTouches(change.change2.modified)))) {
136
- continue;
137
- }
138
- const changeType = getChangeType(change.change);
139
- const startLineNumber = change.change.modifiedStartLineNumber;
140
- const endLineNumber = change.change.modifiedEndLineNumber || startLineNumber;
141
- switch (changeType) {
142
- case ChangeType.Add:
143
- decorations.push({
144
- range: {
145
- startLineNumber: startLineNumber,
146
- startColumn: 1,
147
- endLineNumber: endLineNumber,
148
- endColumn: 1
149
- },
150
- options: quickDiff.kind === "primary" || quickDiff.kind === "contributed" ? pattern.added ? this.addedPatternOptions : this.addedOptions : pattern.added ? this.addedSecondaryPatternOptions : this.addedSecondaryOptions
151
- });
152
- break;
153
- case ChangeType.Delete:
154
- decorations.push({
155
- range: {
156
- startLineNumber: startLineNumber,
157
- startColumn: Number.MAX_VALUE,
158
- endLineNumber: startLineNumber,
159
- endColumn: Number.MAX_VALUE
160
- },
161
- options: quickDiff.kind === "primary" || quickDiff.kind === "contributed" ? this.deletedOptions : this.deletedSecondaryOptions
162
- });
163
- break;
164
- case ChangeType.Modify:
165
- decorations.push({
166
- range: {
167
- startLineNumber: startLineNumber,
168
- startColumn: 1,
169
- endLineNumber: endLineNumber,
170
- endColumn: 1
171
- },
172
- options: quickDiff.kind === "primary" || quickDiff.kind === "contributed" ? pattern.modified ? this.modifiedPatternOptions : this.modifiedOptions : pattern.modified ? this.modifiedSecondaryPatternOptions : this.modifiedSecondaryOptions
173
- });
174
- break;
175
- }
176
- }
177
- if (!this.decorationsCollection) {
178
- this.decorationsCollection = this.codeEditor.createDecorationsCollection(decorations);
179
- } else {
180
- this.decorationsCollection.set(decorations);
181
- }
182
- }
183
- dispose() {
184
- if (this.decorationsCollection) {
185
- this.decorationsCollection.clear();
186
- }
187
- this.decorationsCollection = undefined;
188
- this.quickDiffModelRef.dispose();
189
- super.dispose();
190
- }
191
- };
192
- QuickDiffDecorator = QuickDiffDecorator_1 = ( __decorate([( __param(2, IConfigurationService)), ( __param(3, IQuickDiffService))], QuickDiffDecorator));
193
- let QuickDiffWorkbenchController = class QuickDiffWorkbenchController extends Disposable {
194
- constructor(
195
- editorService,
196
- configurationService,
197
- quickDiffModelService,
198
- quickDiffService,
199
- uriIdentityService,
200
- contextKeyService
201
- ) {
202
- super();
203
- this.editorService = editorService;
204
- this.configurationService = configurationService;
205
- this.quickDiffModelService = quickDiffModelService;
206
- this.quickDiffService = quickDiffService;
207
- this.uriIdentityService = uriIdentityService;
208
- this.enabled = false;
209
- this.decorators = ( new ResourceMap());
210
- this.viewState = {
211
- width: 3,
212
- visibility: "always"
213
- };
214
- this.transientDisposables = this._register(( new DisposableStore()));
215
- this.stylesheet = createStyleSheet(undefined, undefined, this._store);
216
- this.quickDiffDecorationCount = quickDiffDecorationCount.bindTo(contextKeyService);
217
- this.activeEditor = observableFromEvent(
218
- this,
219
- this.editorService.onDidActiveEditorChange,
220
- () => this.editorService.activeEditor
221
- );
222
- this.quickDiffProviders = observableFromEvent(
223
- this,
224
- this.quickDiffService.onDidChangeQuickDiffProviders,
225
- () => this.quickDiffService.providers
226
- );
227
- const onDidChangeConfiguration = Event.filter(
228
- configurationService.onDidChangeConfiguration,
229
- e => e.affectsConfiguration("scm.diffDecorations")
230
- );
231
- this._register(onDidChangeConfiguration(this.onDidChangeConfiguration, this));
232
- this.onDidChangeConfiguration();
233
- const onDidChangeDiffWidthConfiguration = Event.filter(
234
- configurationService.onDidChangeConfiguration,
235
- e => e.affectsConfiguration("scm.diffDecorationsGutterWidth")
236
- );
237
- this._register(
238
- onDidChangeDiffWidthConfiguration(this.onDidChangeDiffWidthConfiguration, this)
239
- );
240
- this.onDidChangeDiffWidthConfiguration();
241
- const onDidChangeDiffVisibilityConfiguration = Event.filter(
242
- configurationService.onDidChangeConfiguration,
243
- e => e.affectsConfiguration("scm.diffDecorationsGutterVisibility")
244
- );
245
- this._register(
246
- onDidChangeDiffVisibilityConfiguration(this.onDidChangeDiffVisibilityConfiguration, this)
247
- );
248
- this.onDidChangeDiffVisibilityConfiguration();
249
- }
250
- onDidChangeConfiguration() {
251
- const enabled = this.configurationService.getValue("scm.diffDecorations") !== "none";
252
- if (enabled) {
253
- this.enable();
254
- } else {
255
- this.disable();
256
- }
257
- }
258
- onDidChangeDiffWidthConfiguration() {
259
- let width = this.configurationService.getValue("scm.diffDecorationsGutterWidth");
260
- if (isNaN(width) || width <= 0 || width > 5) {
261
- width = 3;
262
- }
263
- this.setViewState({
264
- ...this.viewState,
265
- width
266
- });
267
- }
268
- onDidChangeDiffVisibilityConfiguration() {
269
- const visibility = this.configurationService.getValue("scm.diffDecorationsGutterVisibility");
270
- this.setViewState({
271
- ...this.viewState,
272
- visibility
273
- });
274
- }
275
- setViewState(state) {
276
- this.viewState = state;
277
- this.stylesheet.textContent = `
278
- .monaco-editor .dirty-diff-added,
279
- .monaco-editor .dirty-diff-modified {
280
- border-left-width:${state.width}px;
281
- }
282
- .monaco-editor .dirty-diff-added.pattern,
283
- .monaco-editor .dirty-diff-added.pattern:before,
284
- .monaco-editor .dirty-diff-modified.pattern,
285
- .monaco-editor .dirty-diff-modified.pattern:before {
286
- background-size: ${state.width}px ${state.width}px;
287
- }
288
- .monaco-editor .dirty-diff-added,
289
- .monaco-editor .dirty-diff-modified,
290
- .monaco-editor .dirty-diff-deleted {
291
- opacity: ${state.visibility === "always" ? 1 : 0};
292
- }
293
- `;
294
- }
295
- enable() {
296
- if (this.enabled) {
297
- this.disable();
298
- }
299
- this.transientDisposables.add(Event.any(
300
- this.editorService.onDidCloseEditor,
301
- this.editorService.onDidVisibleEditorsChange
302
- )(() => this.onEditorsChanged()));
303
- this.onEditorsChanged();
304
- this.onDidActiveEditorChange();
305
- this.onDidChangeQuickDiffProviders();
306
- this.enabled = true;
307
- }
308
- disable() {
309
- if (!this.enabled) {
310
- return;
311
- }
312
- this.transientDisposables.clear();
313
- this.quickDiffDecorationCount.set(0);
314
- for (const [uri, decoratorMap] of this.decorators.entries()) {
315
- decoratorMap.dispose();
316
- this.decorators.delete(uri);
317
- }
318
- this.enabled = false;
319
- }
320
- onDidActiveEditorChange() {
321
- this.transientDisposables.add(autorun(reader => {
322
- const activeEditor = this.activeEditor.read(reader);
323
- const activeTextEditorControl = this.editorService.activeTextEditorControl;
324
- if (!isCodeEditor(activeTextEditorControl) || !activeEditor?.resource) {
325
- this.quickDiffDecorationCount.set(0);
326
- return;
327
- }
328
- const quickDiffModelRef = this.quickDiffModelService.createQuickDiffModelReference(activeEditor.resource);
329
- if (!quickDiffModelRef) {
330
- this.quickDiffDecorationCount.set(0);
331
- return;
332
- }
333
- reader.store.add(quickDiffModelRef);
334
- const visibleDecorationCount = observableFromEvent(this, quickDiffModelRef.object.onDidChange, () => {
335
- const visibleQuickDiffs = quickDiffModelRef.object.quickDiffs.filter(
336
- quickDiff => this.quickDiffService.isQuickDiffProviderVisible(quickDiff.id)
337
- );
338
- return quickDiffModelRef.object.changes.filter(change => ( visibleQuickDiffs.some(quickDiff => quickDiff.id === change.providerId))).length;
339
- });
340
- reader.store.add(autorun(reader => {
341
- const count = visibleDecorationCount.read(reader);
342
- this.quickDiffDecorationCount.set(count);
343
- }));
344
- }));
345
- }
346
- onDidChangeQuickDiffProviders() {
347
- this.transientDisposables.add(autorun(reader => {
348
- const providers = this.quickDiffProviders.read(reader);
349
- const labels = [];
350
- for (let index = 0; index < providers.length; index++) {
351
- const provider = providers[index];
352
- if (labels.includes(provider.label)) {
353
- continue;
354
- }
355
- const visible = this.quickDiffService.isQuickDiffProviderVisible(provider.id);
356
- const group = provider.kind !== "contributed" ? "0_scm" : "1_contributed";
357
- const order = index + 1;
358
- reader.store.add(registerAction2(class extends Action2 {
359
- constructor() {
360
- super({
361
- id: `workbench.scm.action.toggleQuickDiffVisibility.${provider.id}`,
362
- title: provider.label,
363
- toggled: visible ? ContextKeyTrueExpr.INSTANCE : ContextKeyFalseExpr.INSTANCE,
364
- menu: {
365
- id: MenuId.SCMQuickDiffDecorations,
366
- group,
367
- order
368
- },
369
- f1: false
370
- });
371
- }
372
- run(accessor) {
373
- const quickDiffService = accessor.get(IQuickDiffService);
374
- quickDiffService.toggleQuickDiffProviderVisibility(provider.id);
375
- }
376
- }));
377
- labels.push(provider.label);
378
- }
379
- }));
380
- }
381
- onEditorsChanged() {
382
- for (const editor of this.editorService.visibleTextEditorControls) {
383
- if (!isCodeEditor(editor)) {
384
- continue;
385
- }
386
- const textModel = editor.getModel();
387
- if (!textModel) {
388
- continue;
389
- }
390
- const editorId = editor.getId();
391
- if (this.decorators.get(textModel.uri)?.has(editorId)) {
392
- continue;
393
- }
394
- const quickDiffModelRef = this.quickDiffModelService.createQuickDiffModelReference(textModel.uri);
395
- if (!quickDiffModelRef) {
396
- continue;
397
- }
398
- if (!( this.decorators.has(textModel.uri))) {
399
- this.decorators.set(textModel.uri, ( new DisposableMap()));
400
- }
401
- this.decorators.get(textModel.uri).set(editorId, ( new QuickDiffDecorator(
402
- editor,
403
- quickDiffModelRef,
404
- this.configurationService,
405
- this.quickDiffService
406
- )));
407
- }
408
- for (const [uri, decoratorMap] of this.decorators.entries()) {
409
- for (const editorId of ( decoratorMap.keys())) {
410
- const codeEditor = this.editorService.visibleTextEditorControls.find(
411
- editor => isCodeEditor(editor) && editor.getId() === editorId && this.uriIdentityService.extUri.isEqual(editor.getModel()?.uri, uri)
412
- );
413
- if (!codeEditor) {
414
- decoratorMap.deleteAndDispose(editorId);
415
- }
416
- }
417
- if (decoratorMap.size === 0) {
418
- decoratorMap.dispose();
419
- this.decorators.delete(uri);
420
- }
421
- }
422
- }
423
- dispose() {
424
- this.disable();
425
- super.dispose();
426
- }
427
- };
428
- QuickDiffWorkbenchController = ( __decorate([( __param(0, IEditorService)), ( __param(1, IConfigurationService)), ( __param(2, IQuickDiffModelService)), ( __param(3, IQuickDiffService)), ( __param(4, IUriIdentityService)), ( __param(5, IContextKeyService))], QuickDiffWorkbenchController));
429
-
430
- export { QuickDiffWorkbenchController, quickDiffDecorationCount };