@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,215 +1,215 @@
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 { injectable, inject } from '@theia/core/shared/inversify';
18
- import { DisposableCollection } from '@theia/core';
19
- import { Message } from '@theia/core/shared/@phosphor/messaging';
20
- import * as React from '@theia/core/shared/react';
21
- import TextareaAutosize from 'react-autosize-textarea';
22
- import { ScmInput, ScmInputIssueType } from './scm-input';
23
- import {
24
- ContextMenuRenderer, ReactWidget, KeybindingRegistry, StatefulWidget
25
- } from '@theia/core/lib/browser';
26
- import { ScmService } from './scm-service';
27
-
28
- @injectable()
29
- export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
30
-
31
- static ID = 'scm-commit-widget';
32
-
33
- @inject(ScmService) protected readonly scmService: ScmService;
34
- @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;
35
-
36
- protected readonly toDisposeOnRepositoryChange = new DisposableCollection();
37
-
38
- protected shouldScrollToRow = true;
39
-
40
- /**
41
- * Don't modify DOM use React! only exposed for `focusInput`
42
- * Use `this.scmService.selectedRepository?.input.value` as a single source of truth!
43
- */
44
- protected readonly inputRef = React.createRef<HTMLTextAreaElement>();
45
-
46
- constructor(
47
- @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer,
48
- ) {
49
- super();
50
- this.scrollOptions = {
51
- suppressScrollX: true,
52
- minScrollbarLength: 35
53
- };
54
- this.addClass('theia-scm-commit');
55
- this.id = ScmCommitWidget.ID;
56
- }
57
-
58
- protected override onAfterAttach(msg: Message): void {
59
- super.onAfterAttach(msg);
60
- this.refreshOnRepositoryChange();
61
- this.toDisposeOnDetach.push(this.scmService.onDidChangeSelectedRepository(() => {
62
- this.refreshOnRepositoryChange();
63
- this.update();
64
- }));
65
- }
66
-
67
- protected refreshOnRepositoryChange(): void {
68
- this.toDisposeOnRepositoryChange.dispose();
69
- const repository = this.scmService.selectedRepository;
70
- if (repository) {
71
- this.toDisposeOnRepositoryChange.push(repository.provider.onDidChange(async () => {
72
- this.update();
73
- }));
74
- this.toDisposeOnRepositoryChange.push(repository.provider.onDidChangeCommitTemplate(e => {
75
- this.setInputValue(e);
76
- }));
77
- }
78
- }
79
-
80
- protected override onActivateRequest(msg: Message): void {
81
- super.onActivateRequest(msg);
82
- this.focus();
83
- }
84
-
85
- public focus(): void {
86
- (this.inputRef.current || this.node).focus();
87
- }
88
-
89
- protected render(): React.ReactNode {
90
- const repository = this.scmService.selectedRepository;
91
- if (repository) {
92
- return React.createElement('div', this.createContainerAttributes(), this.renderInput(repository.input));
93
- }
94
- }
95
-
96
- /**
97
- * Create the container attributes for the widget.
98
- */
99
- protected createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
100
- return {
101
- style: { flexGrow: 0 }
102
- };
103
- }
104
-
105
- protected renderInput(input: ScmInput): React.ReactNode {
106
- let validationStatus = 'idle';
107
- if (input.issue) {
108
- switch (input.issue.type) {
109
- case ScmInputIssueType.Error:
110
- validationStatus = 'error';
111
- break;
112
- case ScmInputIssueType.Information:
113
- validationStatus = 'info';
114
- break;
115
- case ScmInputIssueType.Warning:
116
- validationStatus = 'warning';
117
- break;
118
- }
119
- }
120
- const validationMessage = input.issue ? input.issue.message : '';
121
- const format = (value: string, ...args: string[]): string => {
122
- if (args.length !== 0) {
123
- return value.replace(/{(\d+)}/g, (found, n) => {
124
- const i = parseInt(n);
125
- return isNaN(i) || i < 0 || i >= args.length ? found : args[i];
126
- });
127
- }
128
- return value;
129
- };
130
-
131
- const keybinding = this.keybindings.acceleratorFor(this.keybindings.getKeybindingsForCommand('scm.acceptInput')[0]).join('+');
132
- const message = format(input.placeholder || '', keybinding);
133
- const textArea = input.visible &&
134
- <TextareaAutosize
135
- className={`${ScmCommitWidget.Styles.INPUT_MESSAGE} theia-input theia-scm-input-message-${validationStatus}`}
136
- id={ScmCommitWidget.Styles.INPUT_MESSAGE}
137
- placeholder={message}
138
- spellCheck={false}
139
- autoFocus={true}
140
- value={input.value}
141
- disabled={!input.enabled}
142
- onChange={this.setInputValue}
143
- ref={this.inputRef}
144
- rows={1}
145
- maxRows={6} /* from VS Code */>
146
- </TextareaAutosize>;
147
- return <div className={ScmCommitWidget.Styles.INPUT_MESSAGE_CONTAINER}>
148
- {textArea}
149
- <div
150
- className={
151
- `${ScmCommitWidget.Styles.VALIDATION_MESSAGE} ${ScmCommitWidget.Styles.NO_SELECT}
152
- theia-scm-validation-message-${validationStatus} theia-scm-input-message-${validationStatus}`
153
- }
154
- style={{
155
- display: !!input.issue ? 'block' : 'none'
156
- }}>{validationMessage}</div>
157
- </div>;
158
- }
159
-
160
- protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => {
161
- const repository = this.scmService.selectedRepository;
162
- if (repository) {
163
- repository.input.value = typeof event === 'string' ? event : event.currentTarget.value;
164
- }
165
- };
166
-
167
- /**
168
- * Store the tree state.
169
- */
170
- storeState(): ScmCommitWidget.State {
171
- const message = this.scmService.selectedRepository?.input.value;
172
- return { message };
173
- }
174
-
175
- /**
176
- * Restore the state.
177
- * @param oldState the old state object.
178
- */
179
- restoreState(oldState: ScmCommitWidget.State): void {
180
- const value = oldState.message;
181
- if (!value) {
182
- return;
183
- }
184
- let repository = this.scmService.selectedRepository;
185
- if (repository) {
186
- repository.input.value = value;
187
- } else {
188
- const listener = this.scmService.onDidChangeSelectedRepository(() => {
189
- repository = this.scmService.selectedRepository;
190
- if (repository) {
191
- listener.dispose();
192
- if (!repository.input.value) {
193
- repository.input.value = value;
194
- }
195
- }
196
- });
197
- this.toDispose.push(listener);
198
- }
199
- }
200
-
201
- }
202
-
203
- export namespace ScmCommitWidget {
204
-
205
- export namespace Styles {
206
- export const INPUT_MESSAGE_CONTAINER = 'theia-scm-input-message-container';
207
- export const INPUT_MESSAGE = 'theia-scm-input-message';
208
- export const VALIDATION_MESSAGE = 'theia-scm-input-validation-message';
209
- export const NO_SELECT = 'no-select';
210
- }
211
-
212
- export interface State {
213
- message?: string
214
- }
215
- }
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 { injectable, inject } from '@theia/core/shared/inversify';
18
+ import { DisposableCollection } from '@theia/core';
19
+ import { Message } from '@theia/core/shared/@phosphor/messaging';
20
+ import * as React from '@theia/core/shared/react';
21
+ import TextareaAutosize from 'react-autosize-textarea';
22
+ import { ScmInput, ScmInputIssueType } from './scm-input';
23
+ import {
24
+ ContextMenuRenderer, ReactWidget, KeybindingRegistry, StatefulWidget
25
+ } from '@theia/core/lib/browser';
26
+ import { ScmService } from './scm-service';
27
+
28
+ @injectable()
29
+ export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
30
+
31
+ static ID = 'scm-commit-widget';
32
+
33
+ @inject(ScmService) protected readonly scmService: ScmService;
34
+ @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;
35
+
36
+ protected readonly toDisposeOnRepositoryChange = new DisposableCollection();
37
+
38
+ protected shouldScrollToRow = true;
39
+
40
+ /**
41
+ * Don't modify DOM use React! only exposed for `focusInput`
42
+ * Use `this.scmService.selectedRepository?.input.value` as a single source of truth!
43
+ */
44
+ protected readonly inputRef = React.createRef<HTMLTextAreaElement>();
45
+
46
+ constructor(
47
+ @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer,
48
+ ) {
49
+ super();
50
+ this.scrollOptions = {
51
+ suppressScrollX: true,
52
+ minScrollbarLength: 35
53
+ };
54
+ this.addClass('theia-scm-commit');
55
+ this.id = ScmCommitWidget.ID;
56
+ }
57
+
58
+ protected override onAfterAttach(msg: Message): void {
59
+ super.onAfterAttach(msg);
60
+ this.refreshOnRepositoryChange();
61
+ this.toDisposeOnDetach.push(this.scmService.onDidChangeSelectedRepository(() => {
62
+ this.refreshOnRepositoryChange();
63
+ this.update();
64
+ }));
65
+ }
66
+
67
+ protected refreshOnRepositoryChange(): void {
68
+ this.toDisposeOnRepositoryChange.dispose();
69
+ const repository = this.scmService.selectedRepository;
70
+ if (repository) {
71
+ this.toDisposeOnRepositoryChange.push(repository.provider.onDidChange(async () => {
72
+ this.update();
73
+ }));
74
+ this.toDisposeOnRepositoryChange.push(repository.provider.onDidChangeCommitTemplate(e => {
75
+ this.setInputValue(e);
76
+ }));
77
+ }
78
+ }
79
+
80
+ protected override onActivateRequest(msg: Message): void {
81
+ super.onActivateRequest(msg);
82
+ this.focus();
83
+ }
84
+
85
+ public focus(): void {
86
+ (this.inputRef.current || this.node).focus();
87
+ }
88
+
89
+ protected render(): React.ReactNode {
90
+ const repository = this.scmService.selectedRepository;
91
+ if (repository) {
92
+ return React.createElement('div', this.createContainerAttributes(), this.renderInput(repository.input));
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Create the container attributes for the widget.
98
+ */
99
+ protected createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
100
+ return {
101
+ style: { flexGrow: 0 }
102
+ };
103
+ }
104
+
105
+ protected renderInput(input: ScmInput): React.ReactNode {
106
+ let validationStatus = 'idle';
107
+ if (input.issue) {
108
+ switch (input.issue.type) {
109
+ case ScmInputIssueType.Error:
110
+ validationStatus = 'error';
111
+ break;
112
+ case ScmInputIssueType.Information:
113
+ validationStatus = 'info';
114
+ break;
115
+ case ScmInputIssueType.Warning:
116
+ validationStatus = 'warning';
117
+ break;
118
+ }
119
+ }
120
+ const validationMessage = input.issue ? input.issue.message : '';
121
+ const format = (value: string, ...args: string[]): string => {
122
+ if (args.length !== 0) {
123
+ return value.replace(/{(\d+)}/g, (found, n) => {
124
+ const i = parseInt(n);
125
+ return isNaN(i) || i < 0 || i >= args.length ? found : args[i];
126
+ });
127
+ }
128
+ return value;
129
+ };
130
+
131
+ const keybinding = this.keybindings.acceleratorFor(this.keybindings.getKeybindingsForCommand('scm.acceptInput')[0]).join('+');
132
+ const message = format(input.placeholder || '', keybinding);
133
+ const textArea = input.visible &&
134
+ <TextareaAutosize
135
+ className={`${ScmCommitWidget.Styles.INPUT_MESSAGE} theia-input theia-scm-input-message-${validationStatus}`}
136
+ id={ScmCommitWidget.Styles.INPUT_MESSAGE}
137
+ placeholder={message}
138
+ spellCheck={false}
139
+ autoFocus={true}
140
+ value={input.value}
141
+ disabled={!input.enabled}
142
+ onChange={this.setInputValue}
143
+ ref={this.inputRef}
144
+ rows={1}
145
+ maxRows={6} /* from VS Code */>
146
+ </TextareaAutosize>;
147
+ return <div className={ScmCommitWidget.Styles.INPUT_MESSAGE_CONTAINER}>
148
+ {textArea}
149
+ <div
150
+ className={
151
+ `${ScmCommitWidget.Styles.VALIDATION_MESSAGE} ${ScmCommitWidget.Styles.NO_SELECT}
152
+ theia-scm-validation-message-${validationStatus} theia-scm-input-message-${validationStatus}`
153
+ }
154
+ style={{
155
+ display: !!input.issue ? 'block' : 'none'
156
+ }}>{validationMessage}</div>
157
+ </div>;
158
+ }
159
+
160
+ protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => {
161
+ const repository = this.scmService.selectedRepository;
162
+ if (repository) {
163
+ repository.input.value = typeof event === 'string' ? event : event.currentTarget.value;
164
+ }
165
+ };
166
+
167
+ /**
168
+ * Store the tree state.
169
+ */
170
+ storeState(): ScmCommitWidget.State {
171
+ const message = this.scmService.selectedRepository?.input.value;
172
+ return { message };
173
+ }
174
+
175
+ /**
176
+ * Restore the state.
177
+ * @param oldState the old state object.
178
+ */
179
+ restoreState(oldState: ScmCommitWidget.State): void {
180
+ const value = oldState.message;
181
+ if (!value) {
182
+ return;
183
+ }
184
+ let repository = this.scmService.selectedRepository;
185
+ if (repository) {
186
+ repository.input.value = value;
187
+ } else {
188
+ const listener = this.scmService.onDidChangeSelectedRepository(() => {
189
+ repository = this.scmService.selectedRepository;
190
+ if (repository) {
191
+ listener.dispose();
192
+ if (!repository.input.value) {
193
+ repository.input.value = value;
194
+ }
195
+ }
196
+ });
197
+ this.toDispose.push(listener);
198
+ }
199
+ }
200
+
201
+ }
202
+
203
+ export namespace ScmCommitWidget {
204
+
205
+ export namespace Styles {
206
+ export const INPUT_MESSAGE_CONTAINER = 'theia-scm-input-message-container';
207
+ export const INPUT_MESSAGE = 'theia-scm-input-message';
208
+ export const VALIDATION_MESSAGE = 'theia-scm-input-validation-message';
209
+ export const NO_SELECT = 'no-select';
210
+ }
211
+
212
+ export interface State {
213
+ message?: string
214
+ }
215
+ }
@@ -1,46 +1,46 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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 { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
- import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
19
-
20
- @injectable()
21
- export class ScmContextKeyService {
22
-
23
- @inject(ContextKeyService)
24
- protected readonly contextKeyService: ContextKeyService;
25
-
26
- protected _scmProvider: ContextKey<string | undefined>;
27
- get scmProvider(): ContextKey<string | undefined> {
28
- return this._scmProvider;
29
- }
30
-
31
- protected _scmResourceGroup: ContextKey<string | undefined>;
32
- get scmResourceGroup(): ContextKey<string | undefined> {
33
- return this._scmResourceGroup;
34
- }
35
-
36
- @postConstruct()
37
- protected init(): void {
38
- this._scmProvider = this.contextKeyService.createKey<string | undefined>('scmProvider', undefined);
39
- this._scmResourceGroup = this.contextKeyService.createKey<string | undefined>('scmResourceGroup', undefined);
40
- }
41
-
42
- match(expression: string | undefined): boolean {
43
- return !expression || this.contextKeyService.match(expression);
44
- }
45
-
46
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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 { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
+ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
19
+
20
+ @injectable()
21
+ export class ScmContextKeyService {
22
+
23
+ @inject(ContextKeyService)
24
+ protected readonly contextKeyService: ContextKeyService;
25
+
26
+ protected _scmProvider: ContextKey<string | undefined>;
27
+ get scmProvider(): ContextKey<string | undefined> {
28
+ return this._scmProvider;
29
+ }
30
+
31
+ protected _scmResourceGroup: ContextKey<string | undefined>;
32
+ get scmResourceGroup(): ContextKey<string | undefined> {
33
+ return this._scmResourceGroup;
34
+ }
35
+
36
+ @postConstruct()
37
+ protected init(): void {
38
+ this._scmProvider = this.contextKeyService.createKey<string | undefined>('scmProvider', undefined);
39
+ this._scmResourceGroup = this.contextKeyService.createKey<string | undefined>('scmResourceGroup', undefined);
40
+ }
41
+
42
+ match(expression: string | undefined): boolean {
43
+ return !expression || this.contextKeyService.match(expression);
44
+ }
45
+
46
+ }