@theia/scm 1.71.0-next.43 → 1.71.0-next.49

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 +1 @@
1
- {"version":3,"file":"scm-service.d.ts","sourceRoot":"","sources":["../../src/browser/scm-service.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,GAAG,MAAM,4BAA4B,CAAC;AAE7C,qBACa,UAAU;IAGnB,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAErD,SAAS,CAAC,QAAQ,CAAC,aAAa,6BAAoC;IACpE,SAAS,CAAC,mBAAmB,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzD,SAAS,CAAC,QAAQ,CAAC,oCAAoC,qCAA4C;IACnG,QAAQ,CAAC,6BAA6B,oEAAmD;IAEzF,SAAS,CAAC,QAAQ,CAAC,yBAAyB,yBAAgC;IAC5E,QAAQ,CAAC,kBAAkB,wDAAwC;IAEnE,SAAS,CAAC,QAAQ,CAAC,4BAA4B,yBAAgC;IAC/E,QAAQ,CAAC,qBAAqB,wDAA2C;IAEzE,SAAS,CAAC,QAAQ,CAAC,mCAAmC,wBAA+B;IACrF,QAAQ,CAAC,4BAA4B,uDAAkD;IACvF,SAAS,CAAC,8BAA8B,IAAI,IAAI;IAGhD,IAAI,iBAAiB,IAAI,UAAU,EAAE,CAGpC;IAED,IAAI,YAAY,IAAI,aAAa,EAAE,CAElC;IAED,IAAI,kBAAkB,IAAI,aAAa,GAAG,SAAS,CAElD;IAED,SAAS,CAAC,QAAQ,CAAC,mBAAmB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AElC;IAED,IAAI,kBAAkB,IAAI,aAAa,GAAG,SAAS,CAElD;IAED,SAAS,CAAC,QAAQ,CAAC,mBAAmB,uBAA8B;IACpE,IAAI,kBAAkB,CAAC,UAAU,EAAE,aAAa,GAAG,SAAS,EAa3D;IAED,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,aAAa,GAAG,SAAS;IAOnD,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAE,kBAAuB,GAAG,aAAa;CA0B9F"}
@@ -77,10 +77,13 @@ let ScmService = class ScmService {
77
77
  repository.dispose = () => {
78
78
  this._repositories.delete(key);
79
79
  dispose.bind(repository)();
80
- this.onDidRemoveRepositoryEmitter.fire(repository);
80
+ // Update the selected repository before firing the remove event so
81
+ // subscribers do not observe a stale selection pointing at the just
82
+ // disposed repository.
81
83
  if (this._selectedRepository === repository) {
82
84
  this.selectedRepository = this._repositories.values().next().value;
83
85
  }
86
+ this.onDidRemoveRepositoryEmitter.fire(repository);
84
87
  };
85
88
  this._repositories.set(key, repository);
86
89
  this.onDidAddRepositoryEmitter.fire(repository);
@@ -1 +1 @@
1
- {"version":3,"file":"scm-service.js","sourceRoot":"","sources":["../../src/browser/scm-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,uDAAuD;AAEvD,mDAAuE;AACvE,4DAAkE;AAClE,uEAAiE;AACjE,qDAAqE;AAErE,oDAA6C;AAGtC,IAAM,UAAU,GAAhB,MAAM,UAAU;IAAhB;QAKgB,kBAAa,GAAG,IAAI,GAAG,EAAyB,CAAC;QAGjD,yCAAoC,GAAG,IAAI,gBAAO,EAA6B,CAAC;QAC1F,kCAA6B,GAA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Aa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,mEAAmE;YACnE,oEAAoE;YACpE,uBAAuB;YACvB,IAAI,IAAI,CAAC,mBAAmB,KAAK,UAAU,EAAE,CAAC;gBAC1C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YACvE,CAAC;YACD,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACxC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,kBAAkB,GAAG,UAAU,CAAC;QACzC,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CAEJ,CAAA;AApFY,gCAAU;AAGA;IADlB,IAAA,kBAAM,EAAC,8CAAoB,CAAC;sCACG,8CAAoB;+CAAC;qBAH5C,UAAU;IADtB,IAAA,sBAAU,GAAE;GACA,UAAU,CAoFtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=scm-service.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scm-service.spec.d.ts","sourceRoot":"","sources":["../../src/browser/scm-service.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2026 EclipseSource GmbH and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const chai_1 = require("chai");
19
+ const event_1 = require("@theia/core/lib/common/event");
20
+ const scm_service_1 = require("./scm-service");
21
+ function makeProvider(id, rootUri) {
22
+ return {
23
+ id,
24
+ label: id,
25
+ rootUri,
26
+ groups: [],
27
+ onDidChange: new event_1.Emitter().event,
28
+ onDidChangeCommitTemplate: new event_1.Emitter().event,
29
+ dispose: () => { }
30
+ };
31
+ }
32
+ describe('ScmService - repository removal event ordering', () => {
33
+ let service;
34
+ beforeEach(() => {
35
+ service = new scm_service_1.ScmService();
36
+ // ScmService declares a ScmContextKeyService injection but does not use it
37
+ // in the paths exercised here. Stub it to stay resilient against future use.
38
+ service.contextKeys = {};
39
+ });
40
+ it('should update selectedRepository before firing onDidRemoveRepository', () => {
41
+ const repoA = service.registerScmProvider(makeProvider('git', '/a'));
42
+ const repoB = service.registerScmProvider(makeProvider('git', '/b'));
43
+ // Select repoA explicitly (registerScmProvider auto-selects the first one).
44
+ service.selectedRepository = repoA;
45
+ (0, chai_1.expect)(service.selectedRepository).to.equal(repoA);
46
+ let selectedDuringRemoveEvent;
47
+ service.onDidRemoveRepository(() => {
48
+ selectedDuringRemoveEvent = service.selectedRepository;
49
+ });
50
+ repoA.dispose();
51
+ // When a subscriber of onDidRemoveRepository inspects selectedRepository,
52
+ // it must not observe the disposed repository as still being selected.
53
+ (0, chai_1.expect)(selectedDuringRemoveEvent).to.not.equal(repoA);
54
+ (0, chai_1.expect)(selectedDuringRemoveEvent).to.equal(repoB);
55
+ (0, chai_1.expect)(service.selectedRepository).to.equal(repoB);
56
+ });
57
+ it('should clear selectedRepository to undefined when the last repository is removed', () => {
58
+ const repo = service.registerScmProvider(makeProvider('git', '/a'));
59
+ (0, chai_1.expect)(service.selectedRepository).to.equal(repo);
60
+ let selectedDuringRemoveEvent = 'unset';
61
+ service.onDidRemoveRepository(() => {
62
+ selectedDuringRemoveEvent = service.selectedRepository;
63
+ });
64
+ repo.dispose();
65
+ (0, chai_1.expect)(selectedDuringRemoveEvent).to.be.undefined;
66
+ (0, chai_1.expect)(service.selectedRepository).to.be.undefined;
67
+ });
68
+ it('should fire onDidRemoveRepository and leave _repositories empty after disposing the only repo', () => {
69
+ const repo = service.registerScmProvider(makeProvider('git', '/a'));
70
+ let removed;
71
+ service.onDidRemoveRepository(r => { removed = r; });
72
+ repo.dispose();
73
+ (0, chai_1.expect)(removed).to.equal(repo);
74
+ (0, chai_1.expect)(service.repositories).to.have.length(0);
75
+ });
76
+ });
77
+ //# sourceMappingURL=scm-service.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scm-service.spec.js","sourceRoot":"","sources":["../../src/browser/scm-service.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,+BAA8B;AAC9B,wDAAuD;AACvD,+CAA2C;AAG3C,SAAS,YAAY,CAAC,EAAU,EAAE,OAAe;IAC7C,OAAO;QACH,EAAE;QACF,KAAK,EAAE,EAAE;QACT,OAAO;QACP,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,IAAI,eAAO,EAAQ,CAAC,KAAK;QACtC,yBAAyB,EAAE,IAAI,eAAO,EAAU,CAAC,KAAK;QACtD,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC;KACK,CAAC;AAChC,CAAC;AAED,QAAQ,CAAC,gD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theia - Source control Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.71.0-next.43+e960af22f",
7
- "@theia/editor": "1.71.0-next.43+e960af22f",
8
- "@theia/filesystem": "1.71.0-next.43+e960af22f",
9
- "@theia/monaco": "1.71.0-next.43+e960af22f",
6
+ "@theia/core": "1.71.0-next.49+ff8893f59",
7
+ "@theia/editor": "1.71.0-next.49+ff8893f59",
8
+ "@theia/filesystem": "1.71.0-next.49+ff8893f59",
9
+ "@theia/monaco": "1.71.0-next.49+ff8893f59",
10
10
  "@theia/monaco-editor-core": "1.108.201",
11
11
  "@types/diff": "^5.2.3",
12
12
  "diff": "^5.2.2",
@@ -55,5 +55,5 @@
55
55
  "nyc": {
56
56
  "extends": "../../configs/nyc.json"
57
57
  },
58
- "gitHead": "e960af22fd0721f7cd4a8f7d66e6e9d10c801962"
58
+ "gitHead": "ff8893f5957f8e505176ecd8c3ef10d722d47172"
59
59
  }
@@ -0,0 +1,91 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 EclipseSource GmbH and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { expect } from 'chai';
18
+ import { Emitter } from '@theia/core/lib/common/event';
19
+ import { ScmService } from './scm-service';
20
+ import { ScmProvider } from './scm-provider';
21
+
22
+ function makeProvider(id: string, rootUri: string): ScmProvider {
23
+ return {
24
+ id,
25
+ label: id,
26
+ rootUri,
27
+ groups: [],
28
+ onDidChange: new Emitter<void>().event,
29
+ onDidChangeCommitTemplate: new Emitter<string>().event,
30
+ dispose: () => { }
31
+ } as unknown as ScmProvider;
32
+ }
33
+
34
+ describe('ScmService - repository removal event ordering', () => {
35
+ let service: ScmService;
36
+
37
+ beforeEach(() => {
38
+ service = new ScmService();
39
+ // ScmService declares a ScmContextKeyService injection but does not use it
40
+ // in the paths exercised here. Stub it to stay resilient against future use.
41
+ (service as unknown as Record<string, unknown>).contextKeys = {};
42
+ });
43
+
44
+ it('should update selectedRepository before firing onDidRemoveRepository', () => {
45
+ const repoA = service.registerScmProvider(makeProvider('git', '/a'));
46
+ const repoB = service.registerScmProvider(makeProvider('git', '/b'));
47
+
48
+ // Select repoA explicitly (registerScmProvider auto-selects the first one).
49
+ service.selectedRepository = repoA;
50
+ expect(service.selectedRepository).to.equal(repoA);
51
+
52
+ let selectedDuringRemoveEvent: unknown;
53
+ service.onDidRemoveRepository(() => {
54
+ selectedDuringRemoveEvent = service.selectedRepository;
55
+ });
56
+
57
+ repoA.dispose();
58
+
59
+ // When a subscriber of onDidRemoveRepository inspects selectedRepository,
60
+ // it must not observe the disposed repository as still being selected.
61
+ expect(selectedDuringRemoveEvent).to.not.equal(repoA);
62
+ expect(selectedDuringRemoveEvent).to.equal(repoB);
63
+ expect(service.selectedRepository).to.equal(repoB);
64
+ });
65
+
66
+ it('should clear selectedRepository to undefined when the last repository is removed', () => {
67
+ const repo = service.registerScmProvider(makeProvider('git', '/a'));
68
+ expect(service.selectedRepository).to.equal(repo);
69
+
70
+ let selectedDuringRemoveEvent: unknown = 'unset';
71
+ service.onDidRemoveRepository(() => {
72
+ selectedDuringRemoveEvent = service.selectedRepository;
73
+ });
74
+
75
+ repo.dispose();
76
+
77
+ expect(selectedDuringRemoveEvent).to.be.undefined;
78
+ expect(service.selectedRepository).to.be.undefined;
79
+ });
80
+
81
+ it('should fire onDidRemoveRepository and leave _repositories empty after disposing the only repo', () => {
82
+ const repo = service.registerScmProvider(makeProvider('git', '/a'));
83
+ let removed: unknown;
84
+ service.onDidRemoveRepository(r => { removed = r; });
85
+
86
+ repo.dispose();
87
+
88
+ expect(removed).to.equal(repo);
89
+ expect(service.repositories).to.have.length(0);
90
+ });
91
+ });
@@ -92,10 +92,13 @@ export class ScmService {
92
92
  repository.dispose = () => {
93
93
  this._repositories.delete(key);
94
94
  dispose.bind(repository)();
95
- this.onDidRemoveRepositoryEmitter.fire(repository);
95
+ // Update the selected repository before firing the remove event so
96
+ // subscribers do not observe a stale selection pointing at the just
97
+ // disposed repository.
96
98
  if (this._selectedRepository === repository) {
97
99
  this.selectedRepository = this._repositories.values().next().value;
98
100
  }
101
+ this.onDidRemoveRepositoryEmitter.fire(repository);
99
102
  };
100
103
  this._repositories.set(key, repository);
101
104
  this.onDidAddRepositoryEmitter.fire(repository);