@theia/scm 1.53.0-next.5 → 1.53.0-next.55

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 (41) hide show
  1. package/README.md +31 -31
  2. package/lib/browser/scm-commit-widget.js +1 -1
  3. package/lib/browser/scm-contribution.js +5 -5
  4. package/package.json +7 -7
  5. package/src/browser/decorations/scm-decorations-service.ts +102 -102
  6. package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
  7. package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
  8. package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
  9. package/src/browser/dirty-diff/content-lines.ts +121 -121
  10. package/src/browser/dirty-diff/diff-computer.spec.ts +455 -455
  11. package/src/browser/dirty-diff/diff-computer.ts +177 -177
  12. package/src/browser/dirty-diff/dirty-diff-decorator.ts +114 -114
  13. package/src/browser/dirty-diff/dirty-diff-module.ts +33 -33
  14. package/src/browser/dirty-diff/dirty-diff-navigator.ts +288 -288
  15. package/src/browser/dirty-diff/dirty-diff-widget.ts +364 -364
  16. package/src/browser/scm-amend-component.tsx +600 -600
  17. package/src/browser/scm-amend-widget.tsx +77 -77
  18. package/src/browser/scm-avatar-service.ts +27 -27
  19. package/src/browser/scm-colors.ts +21 -21
  20. package/src/browser/scm-commit-widget.tsx +215 -215
  21. package/src/browser/scm-context-key-service.ts +46 -46
  22. package/src/browser/scm-contribution.ts +452 -452
  23. package/src/browser/scm-frontend-module.ts +149 -149
  24. package/src/browser/scm-groups-tree-model.ts +78 -78
  25. package/src/browser/scm-input.ts +164 -164
  26. package/src/browser/scm-layout-migrations.ts +64 -64
  27. package/src/browser/scm-no-repository-widget.tsx +41 -41
  28. package/src/browser/scm-preferences.ts +63 -63
  29. package/src/browser/scm-provider.ts +91 -91
  30. package/src/browser/scm-quick-open-service.ts +48 -48
  31. package/src/browser/scm-repository.ts +52 -52
  32. package/src/browser/scm-service.ts +108 -108
  33. package/src/browser/scm-tree-label-provider.ts +44 -44
  34. package/src/browser/scm-tree-model.ts +405 -405
  35. package/src/browser/scm-tree-widget.tsx +838 -838
  36. package/src/browser/scm-widget.tsx +204 -204
  37. package/src/browser/style/dirty-diff-decorator.css +53 -53
  38. package/src/browser/style/dirty-diff.css +50 -50
  39. package/src/browser/style/index.css +271 -271
  40. package/src/browser/style/scm-amend-component.css +94 -94
  41. package/src/browser/style/scm.svg +4 -4
@@ -1,83 +1,83 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Ericsson 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 { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
- import { Event, Emitter } from '@theia/core/lib/common/event';
19
- import { ScmService } from '../scm-service';
20
- import { TabBarDecorator } from '@theia/core/lib/browser/shell/tab-bar-decorator';
21
- import { Title, ViewContainer, Widget } from '@theia/core/lib/browser';
22
- import { WidgetDecoration } from '@theia/core/lib/browser/widget-decoration';
23
- import { DisposableCollection } from '@theia/core/lib/common/disposable';
24
- import { ScmWidget } from '../scm-widget';
25
-
26
- @injectable()
27
- export class ScmTabBarDecorator implements TabBarDecorator {
28
-
29
- readonly id = 'theia-scm-tabbar-decorator';
30
- protected readonly emitter = new Emitter<void>();
31
-
32
- private readonly toDispose = new DisposableCollection();
33
- private readonly toDisposeOnDidChange = new DisposableCollection();
34
-
35
- @inject(ScmService)
36
- protected readonly scmService: ScmService;
37
-
38
- @postConstruct()
39
- protected init(): void {
40
- this.toDispose.push(this.scmService.onDidChangeSelectedRepository(repository => {
41
- this.toDisposeOnDidChange.dispose();
42
- if (repository) {
43
- this.toDisposeOnDidChange.push(
44
- repository.provider.onDidChange(() => this.fireDidChangeDecorations())
45
- );
46
- }
47
- this.fireDidChangeDecorations();
48
- }));
49
- }
50
-
51
- decorate(title: Title<Widget>): WidgetDecoration.Data[] {
52
- const { owner } = title;
53
- if (owner instanceof ViewContainer && owner.getParts().find(part => part.wrapped instanceof ScmWidget)) {
54
- const changes = this.collectChangesCount();
55
- return changes > 0 ? [{ badge: changes }] : [];
56
- } else {
57
- return [];
58
- }
59
- }
60
-
61
- protected collectChangesCount(): number {
62
- const repository = this.scmService.selectedRepository;
63
- let changes = 0;
64
- if (!repository) {
65
- return 0;
66
- }
67
- repository.provider.groups.map(group => {
68
- if (group.id === 'index' || group.id === 'workingTree') {
69
- changes += group.resources.length;
70
- }
71
- });
72
- return changes;
73
- }
74
-
75
- get onDidChangeDecorations(): Event<void> {
76
- return this.emitter.event;
77
- }
78
-
79
- protected fireDidChangeDecorations(): void {
80
- this.emitter.fire(undefined);
81
- }
82
-
83
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 Ericsson 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 { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
+ import { Event, Emitter } from '@theia/core/lib/common/event';
19
+ import { ScmService } from '../scm-service';
20
+ import { TabBarDecorator } from '@theia/core/lib/browser/shell/tab-bar-decorator';
21
+ import { Title, ViewContainer, Widget } from '@theia/core/lib/browser';
22
+ import { WidgetDecoration } from '@theia/core/lib/browser/widget-decoration';
23
+ import { DisposableCollection } from '@theia/core/lib/common/disposable';
24
+ import { ScmWidget } from '../scm-widget';
25
+
26
+ @injectable()
27
+ export class ScmTabBarDecorator implements TabBarDecorator {
28
+
29
+ readonly id = 'theia-scm-tabbar-decorator';
30
+ protected readonly emitter = new Emitter<void>();
31
+
32
+ private readonly toDispose = new DisposableCollection();
33
+ private readonly toDisposeOnDidChange = new DisposableCollection();
34
+
35
+ @inject(ScmService)
36
+ protected readonly scmService: ScmService;
37
+
38
+ @postConstruct()
39
+ protected init(): void {
40
+ this.toDispose.push(this.scmService.onDidChangeSelectedRepository(repository => {
41
+ this.toDisposeOnDidChange.dispose();
42
+ if (repository) {
43
+ this.toDisposeOnDidChange.push(
44
+ repository.provider.onDidChange(() => this.fireDidChangeDecorations())
45
+ );
46
+ }
47
+ this.fireDidChangeDecorations();
48
+ }));
49
+ }
50
+
51
+ decorate(title: Title<Widget>): WidgetDecoration.Data[] {
52
+ const { owner } = title;
53
+ if (owner instanceof ViewContainer && owner.getParts().find(part => part.wrapped instanceof ScmWidget)) {
54
+ const changes = this.collectChangesCount();
55
+ return changes > 0 ? [{ badge: changes }] : [];
56
+ } else {
57
+ return [];
58
+ }
59
+ }
60
+
61
+ protected collectChangesCount(): number {
62
+ const repository = this.scmService.selectedRepository;
63
+ let changes = 0;
64
+ if (!repository) {
65
+ return 0;
66
+ }
67
+ repository.provider.groups.map(group => {
68
+ if (group.id === 'index' || group.id === 'workingTree') {
69
+ changes += group.resources.length;
70
+ }
71
+ });
72
+ return changes;
73
+ }
74
+
75
+ get onDidChangeDecorations(): Event<void> {
76
+ return this.emitter.event;
77
+ }
78
+
79
+ protected fireDidChangeDecorations(): void {
80
+ this.emitter.fire(undefined);
81
+ }
82
+
83
+ }
@@ -1,42 +1,42 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox 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 * as chai from 'chai';
18
- import { ContentLines } from './content-lines';
19
- import { expect } from 'chai';
20
- chai.use(require('chai-string'));
21
-
22
- describe('content-lines', () => {
23
-
24
- it('array-like access of lines without splitting', () => {
25
- const raw = 'abc\ndef\n123\n456';
26
- const linesArray = ContentLines.arrayLike(ContentLines.fromString(raw));
27
- expect(linesArray[0]).to.be.equal('abc');
28
- expect(linesArray[1]).to.be.equal('def');
29
- expect(linesArray[2]).to.be.equal('123');
30
- expect(linesArray[3]).to.be.equal('456');
31
- });
32
-
33
- it('works with CRLF', () => {
34
- const raw = 'abc\ndef\r\n123\r456';
35
- const linesArray = ContentLines.arrayLike(ContentLines.fromString(raw));
36
- expect(linesArray[0]).to.be.equal('abc');
37
- expect(linesArray[1]).to.be.equal('def');
38
- expect(linesArray[2]).to.be.equal('123');
39
- expect(linesArray[3]).to.be.equal('456');
40
- });
41
-
42
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox 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 * as chai from 'chai';
18
+ import { ContentLines } from './content-lines';
19
+ import { expect } from 'chai';
20
+ chai.use(require('chai-string'));
21
+
22
+ describe('content-lines', () => {
23
+
24
+ it('array-like access of lines without splitting', () => {
25
+ const raw = 'abc\ndef\n123\n456';
26
+ const linesArray = ContentLines.arrayLike(ContentLines.fromString(raw));
27
+ expect(linesArray[0]).to.be.equal('abc');
28
+ expect(linesArray[1]).to.be.equal('def');
29
+ expect(linesArray[2]).to.be.equal('123');
30
+ expect(linesArray[3]).to.be.equal('456');
31
+ });
32
+
33
+ it('works with CRLF', () => {
34
+ const raw = 'abc\ndef\r\n123\r456';
35
+ const linesArray = ContentLines.arrayLike(ContentLines.fromString(raw));
36
+ expect(linesArray[0]).to.be.equal('abc');
37
+ expect(linesArray[1]).to.be.equal('def');
38
+ expect(linesArray[2]).to.be.equal('123');
39
+ expect(linesArray[3]).to.be.equal('456');
40
+ });
41
+
42
+ });
@@ -1,121 +1,121 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox 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 { TextEditorDocument } from '@theia/editor/lib/browser';
18
-
19
- export interface ContentLines extends ArrayLike<string> {
20
- readonly length: number,
21
- getLineContent: (line: number) => string,
22
- }
23
-
24
- export interface ContentLinesArrayLike extends ContentLines, ArrayLike<string> {
25
- [Symbol.iterator]: () => IterableIterator<string>,
26
- readonly [n: number]: string;
27
- }
28
-
29
- export namespace ContentLines {
30
- const NL = '\n'.charCodeAt(0);
31
- const CR = '\r'.charCodeAt(0);
32
-
33
- export function fromString(content: string): ContentLines {
34
- const computeLineStarts: (s: string) => number[] = s => {
35
- const result: number[] = [0];
36
- for (let i = 0; i < s.length; i++) {
37
- const chr = s.charCodeAt(i);
38
- if (chr === CR) {
39
- if (i + 1 < s.length && s.charCodeAt(i + 1) === NL) {
40
- result[result.length] = i + 2;
41
- i++;
42
- } else {
43
- result[result.length] = i + 1;
44
- }
45
- } else if (chr === NL) {
46
- result[result.length] = i + 1;
47
- }
48
- }
49
- return result;
50
- };
51
- const lineStarts = computeLineStarts(content);
52
-
53
- return {
54
- length: lineStarts.length,
55
- getLineContent: line => {
56
- if (line >= lineStarts.length) {
57
- throw new Error('line index out of bounds');
58
- }
59
- const start = lineStarts[line];
60
- let end = (line === lineStarts.length - 1) ? undefined : lineStarts[line + 1] - 1;
61
- if (!!end && content.charCodeAt(end - 1) === CR) {
62
- end--; // ignore CR at the end
63
- }
64
- const lineContent = content.substring(start, end);
65
- return lineContent;
66
- }
67
- };
68
- }
69
-
70
- export function fromTextEditorDocument(document: TextEditorDocument): ContentLines {
71
- return {
72
- length: document.lineCount,
73
- getLineContent: line => document.getLineContent(line + 1),
74
- };
75
- }
76
-
77
- export function arrayLike(lines: ContentLines): ContentLinesArrayLike {
78
- return new Proxy(lines as ContentLines, getProxyHandler()) as ContentLinesArrayLike;
79
- }
80
-
81
- function getProxyHandler(): ProxyHandler<ContentLinesArrayLike> {
82
- return {
83
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
- get(target: ContentLines, p: PropertyKey): any {
85
- switch (p) {
86
- case 'prototype':
87
- return undefined;
88
- case 'length':
89
- return target.length;
90
- case 'slice':
91
- return (start?: number, end?: number) => {
92
- if (start !== undefined) {
93
- return [start, (end !== undefined ? end - 1 : target.length - 1)];
94
- }
95
- return [0, target.length - 1];
96
- };
97
- case Symbol.iterator:
98
- return function* (): IterableIterator<string> {
99
- for (let i = 0; i < target.length; i++) {
100
- yield target.getLineContent(i);
101
- }
102
- };
103
- }
104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
- const index = Number.parseInt(p as any);
106
- if (Number.isInteger(index)) {
107
- if (index >= 0 && index < target.length) {
108
- const value = target.getLineContent(index);
109
- if (value === undefined) {
110
- console.log(target);
111
- }
112
- return value;
113
- } else {
114
- return undefined;
115
- }
116
- }
117
- throw new Error(`get ${String(p)} not implemented`);
118
- }
119
- };
120
- }
121
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox 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 { TextEditorDocument } from '@theia/editor/lib/browser';
18
+
19
+ export interface ContentLines extends ArrayLike<string> {
20
+ readonly length: number,
21
+ getLineContent: (line: number) => string,
22
+ }
23
+
24
+ export interface ContentLinesArrayLike extends ContentLines, ArrayLike<string> {
25
+ [Symbol.iterator]: () => IterableIterator<string>,
26
+ readonly [n: number]: string;
27
+ }
28
+
29
+ export namespace ContentLines {
30
+ const NL = '\n'.charCodeAt(0);
31
+ const CR = '\r'.charCodeAt(0);
32
+
33
+ export function fromString(content: string): ContentLines {
34
+ const computeLineStarts: (s: string) => number[] = s => {
35
+ const result: number[] = [0];
36
+ for (let i = 0; i < s.length; i++) {
37
+ const chr = s.charCodeAt(i);
38
+ if (chr === CR) {
39
+ if (i + 1 < s.length && s.charCodeAt(i + 1) === NL) {
40
+ result[result.length] = i + 2;
41
+ i++;
42
+ } else {
43
+ result[result.length] = i + 1;
44
+ }
45
+ } else if (chr === NL) {
46
+ result[result.length] = i + 1;
47
+ }
48
+ }
49
+ return result;
50
+ };
51
+ const lineStarts = computeLineStarts(content);
52
+
53
+ return {
54
+ length: lineStarts.length,
55
+ getLineContent: line => {
56
+ if (line >= lineStarts.length) {
57
+ throw new Error('line index out of bounds');
58
+ }
59
+ const start = lineStarts[line];
60
+ let end = (line === lineStarts.length - 1) ? undefined : lineStarts[line + 1] - 1;
61
+ if (!!end && content.charCodeAt(end - 1) === CR) {
62
+ end--; // ignore CR at the end
63
+ }
64
+ const lineContent = content.substring(start, end);
65
+ return lineContent;
66
+ }
67
+ };
68
+ }
69
+
70
+ export function fromTextEditorDocument(document: TextEditorDocument): ContentLines {
71
+ return {
72
+ length: document.lineCount,
73
+ getLineContent: line => document.getLineContent(line + 1),
74
+ };
75
+ }
76
+
77
+ export function arrayLike(lines: ContentLines): ContentLinesArrayLike {
78
+ return new Proxy(lines as ContentLines, getProxyHandler()) as ContentLinesArrayLike;
79
+ }
80
+
81
+ function getProxyHandler(): ProxyHandler<ContentLinesArrayLike> {
82
+ return {
83
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
+ get(target: ContentLines, p: PropertyKey): any {
85
+ switch (p) {
86
+ case 'prototype':
87
+ return undefined;
88
+ case 'length':
89
+ return target.length;
90
+ case 'slice':
91
+ return (start?: number, end?: number) => {
92
+ if (start !== undefined) {
93
+ return [start, (end !== undefined ? end - 1 : target.length - 1)];
94
+ }
95
+ return [0, target.length - 1];
96
+ };
97
+ case Symbol.iterator:
98
+ return function* (): IterableIterator<string> {
99
+ for (let i = 0; i < target.length; i++) {
100
+ yield target.getLineContent(i);
101
+ }
102
+ };
103
+ }
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ const index = Number.parseInt(p as any);
106
+ if (Number.isInteger(index)) {
107
+ if (index >= 0 && index < target.length) {
108
+ const value = target.getLineContent(index);
109
+ if (value === undefined) {
110
+ console.log(target);
111
+ }
112
+ return value;
113
+ } else {
114
+ return undefined;
115
+ }
116
+ }
117
+ throw new Error(`get ${String(p)} not implemented`);
118
+ }
119
+ };
120
+ }
121
+ }