|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 |
| -import { window, workspace, Uri, Disposable, Event, EventEmitter, FileDecoration, FileDecorationProvider, ThemeColor, l10n } from 'vscode'; |
| 6 | +import { window, workspace, Uri, Disposable, Event, EventEmitter, FileDecoration, FileDecorationProvider, ThemeColor } from 'vscode'; |
7 | 7 | import * as path from 'path';
|
8 | 8 | import { Repository, GitResourceGroup } from './repository';
|
9 | 9 | import { Model } from './model';
|
10 | 10 | import { debounce } from './decorators';
|
11 | 11 | import { filterEvent, dispose, anyEvent, fireEvent, PromiseSource, combinedDisposable } from './util';
|
12 |
| -import { Change, GitErrorCodes, Status } from './api/git'; |
| 12 | +import { GitErrorCodes, Status } from './api/git'; |
13 | 13 |
|
14 | 14 | class GitIgnoreDecorationProvider implements FileDecorationProvider {
|
15 | 15 |
|
@@ -153,100 +153,100 @@ class GitDecorationProvider implements FileDecorationProvider {
|
153 | 153 | }
|
154 | 154 | }
|
155 | 155 |
|
156 |
| -class GitIncomingChangesFileDecorationProvider implements FileDecorationProvider { |
157 |
| - |
158 |
| - private readonly _onDidChangeDecorations = new EventEmitter<Uri[]>(); |
159 |
| - readonly onDidChangeFileDecorations: Event<Uri[]> = this._onDidChangeDecorations.event; |
160 |
| - |
161 |
| - private decorations = new Map<string, FileDecoration>(); |
162 |
| - private readonly disposables: Disposable[] = []; |
163 |
| - |
164 |
| - constructor(private readonly repository: Repository) { |
165 |
| - this.disposables.push(window.registerFileDecorationProvider(this)); |
166 |
| - repository.historyProvider.onDidChangeCurrentHistoryItemGroup(this.onDidChangeCurrentHistoryItemGroup, this, this.disposables); |
167 |
| - } |
168 |
| - |
169 |
| - private async onDidChangeCurrentHistoryItemGroup(): Promise<void> { |
170 |
| - const newDecorations = new Map<string, FileDecoration>(); |
171 |
| - await this.collectIncomingChangesFileDecorations(newDecorations); |
172 |
| - const uris = new Set([...this.decorations.keys()].concat([...newDecorations.keys()])); |
173 |
| - |
174 |
| - this.decorations = newDecorations; |
175 |
| - this._onDidChangeDecorations.fire([...uris.values()].map(value => Uri.parse(value, true))); |
176 |
| - } |
177 |
| - |
178 |
| - private async collectIncomingChangesFileDecorations(bucket: Map<string, FileDecoration>): Promise<void> { |
179 |
| - for (const change of await this.getIncomingChanges()) { |
180 |
| - switch (change.status) { |
181 |
| - case Status.INDEX_ADDED: |
182 |
| - bucket.set(change.uri.toString(), { |
183 |
| - badge: '↓A', |
184 |
| - color: new ThemeColor('gitDecoration.incomingAddedForegroundColor'), |
185 |
| - tooltip: l10n.t('Incoming Changes (added)'), |
186 |
| - }); |
187 |
| - break; |
188 |
| - case Status.DELETED: |
189 |
| - bucket.set(change.uri.toString(), { |
190 |
| - badge: '↓D', |
191 |
| - color: new ThemeColor('gitDecoration.incomingDeletedForegroundColor'), |
192 |
| - tooltip: l10n.t('Incoming Changes (deleted)'), |
193 |
| - }); |
194 |
| - break; |
195 |
| - case Status.INDEX_RENAMED: |
196 |
| - bucket.set(change.originalUri.toString(), { |
197 |
| - badge: '↓R', |
198 |
| - color: new ThemeColor('gitDecoration.incomingRenamedForegroundColor'), |
199 |
| - tooltip: l10n.t('Incoming Changes (renamed)'), |
200 |
| - }); |
201 |
| - break; |
202 |
| - case Status.MODIFIED: |
203 |
| - bucket.set(change.uri.toString(), { |
204 |
| - badge: '↓M', |
205 |
| - color: new ThemeColor('gitDecoration.incomingModifiedForegroundColor'), |
206 |
| - tooltip: l10n.t('Incoming Changes (modified)'), |
207 |
| - }); |
208 |
| - break; |
209 |
| - default: { |
210 |
| - bucket.set(change.uri.toString(), { |
211 |
| - badge: '↓~', |
212 |
| - color: new ThemeColor('gitDecoration.incomingModifiedForegroundColor'), |
213 |
| - tooltip: l10n.t('Incoming Changes'), |
214 |
| - }); |
215 |
| - break; |
216 |
| - } |
217 |
| - } |
218 |
| - } |
219 |
| - } |
220 |
| - |
221 |
| - private async getIncomingChanges(): Promise<Change[]> { |
222 |
| - try { |
223 |
| - const historyProvider = this.repository.historyProvider; |
224 |
| - const currentHistoryItemGroup = historyProvider.currentHistoryItemGroup; |
225 |
| - |
226 |
| - if (!currentHistoryItemGroup?.base) { |
227 |
| - return []; |
228 |
| - } |
229 |
| - |
230 |
| - const ancestor = await historyProvider.resolveHistoryItemGroupCommonAncestor(currentHistoryItemGroup.id, currentHistoryItemGroup.base.id); |
231 |
| - if (!ancestor) { |
232 |
| - return []; |
233 |
| - } |
234 |
| - |
235 |
| - const changes = await this.repository.diffBetween(ancestor.id, currentHistoryItemGroup.base.id); |
236 |
| - return changes; |
237 |
| - } catch (err) { |
238 |
| - return []; |
239 |
| - } |
240 |
| - } |
241 |
| - |
242 |
| - provideFileDecoration(uri: Uri): FileDecoration | undefined { |
243 |
| - return this.decorations.get(uri.toString()); |
244 |
| - } |
245 |
| - |
246 |
| - dispose(): void { |
247 |
| - dispose(this.disposables); |
248 |
| - } |
249 |
| -} |
| 156 | +// class GitIncomingChangesFileDecorationProvider implements FileDecorationProvider { |
| 157 | + |
| 158 | +// private readonly _onDidChangeDecorations = new EventEmitter<Uri[]>(); |
| 159 | +// readonly onDidChangeFileDecorations: Event<Uri[]> = this._onDidChangeDecorations.event; |
| 160 | + |
| 161 | +// private decorations = new Map<string, FileDecoration>(); |
| 162 | +// private readonly disposables: Disposable[] = []; |
| 163 | + |
| 164 | +// constructor(private readonly repository: Repository) { |
| 165 | +// this.disposables.push(window.registerFileDecorationProvider(this)); |
| 166 | +// repository.historyProvider.onDidChangeCurrentHistoryItemGroup(this.onDidChangeCurrentHistoryItemGroup, this, this.disposables); |
| 167 | +// } |
| 168 | + |
| 169 | +// private async onDidChangeCurrentHistoryItemGroup(): Promise<void> { |
| 170 | +// const newDecorations = new Map<string, FileDecoration>(); |
| 171 | +// await this.collectIncomingChangesFileDecorations(newDecorations); |
| 172 | +// const uris = new Set([...this.decorations.keys()].concat([...newDecorations.keys()])); |
| 173 | + |
| 174 | +// this.decorations = newDecorations; |
| 175 | +// this._onDidChangeDecorations.fire([...uris.values()].map(value => Uri.parse(value, true))); |
| 176 | +// } |
| 177 | + |
| 178 | +// private async collectIncomingChangesFileDecorations(bucket: Map<string, FileDecoration>): Promise<void> { |
| 179 | +// for (const change of await this.getIncomingChanges()) { |
| 180 | +// switch (change.status) { |
| 181 | +// case Status.INDEX_ADDED: |
| 182 | +// bucket.set(change.uri.toString(), { |
| 183 | +// badge: '↓A', |
| 184 | +// color: new ThemeColor('gitDecoration.incomingAddedForegroundColor'), |
| 185 | +// tooltip: l10n.t('Incoming Changes (added)'), |
| 186 | +// }); |
| 187 | +// break; |
| 188 | +// case Status.DELETED: |
| 189 | +// bucket.set(change.uri.toString(), { |
| 190 | +// badge: '↓D', |
| 191 | +// color: new ThemeColor('gitDecoration.incomingDeletedForegroundColor'), |
| 192 | +// tooltip: l10n.t('Incoming Changes (deleted)'), |
| 193 | +// }); |
| 194 | +// break; |
| 195 | +// case Status.INDEX_RENAMED: |
| 196 | +// bucket.set(change.originalUri.toString(), { |
| 197 | +// badge: '↓R', |
| 198 | +// color: new ThemeColor('gitDecoration.incomingRenamedForegroundColor'), |
| 199 | +// tooltip: l10n.t('Incoming Changes (renamed)'), |
| 200 | +// }); |
| 201 | +// break; |
| 202 | +// case Status.MODIFIED: |
| 203 | +// bucket.set(change.uri.toString(), { |
| 204 | +// badge: '↓M', |
| 205 | +// color: new ThemeColor('gitDecoration.incomingModifiedForegroundColor'), |
| 206 | +// tooltip: l10n.t('Incoming Changes (modified)'), |
| 207 | +// }); |
| 208 | +// break; |
| 209 | +// default: { |
| 210 | +// bucket.set(change.uri.toString(), { |
| 211 | +// badge: '↓~', |
| 212 | +// color: new ThemeColor('gitDecoration.incomingModifiedForegroundColor'), |
| 213 | +// tooltip: l10n.t('Incoming Changes'), |
| 214 | +// }); |
| 215 | +// break; |
| 216 | +// } |
| 217 | +// } |
| 218 | +// } |
| 219 | +// } |
| 220 | + |
| 221 | +// private async getIncomingChanges(): Promise<Change[]> { |
| 222 | +// try { |
| 223 | +// const historyProvider = this.repository.historyProvider; |
| 224 | +// const currentHistoryItemGroup = historyProvider.currentHistoryItemGroup; |
| 225 | + |
| 226 | +// if (!currentHistoryItemGroup?.base) { |
| 227 | +// return []; |
| 228 | +// } |
| 229 | + |
| 230 | +// const ancestor = await historyProvider.resolveHistoryItemGroupCommonAncestor(currentHistoryItemGroup.id, currentHistoryItemGroup.base.id); |
| 231 | +// if (!ancestor) { |
| 232 | +// return []; |
| 233 | +// } |
| 234 | + |
| 235 | +// const changes = await this.repository.diffBetween(ancestor.id, currentHistoryItemGroup.base.id); |
| 236 | +// return changes; |
| 237 | +// } catch (err) { |
| 238 | +// return []; |
| 239 | +// } |
| 240 | +// } |
| 241 | + |
| 242 | +// provideFileDecoration(uri: Uri): FileDecoration | undefined { |
| 243 | +// return this.decorations.get(uri.toString()); |
| 244 | +// } |
| 245 | + |
| 246 | +// dispose(): void { |
| 247 | +// dispose(this.disposables); |
| 248 | +// } |
| 249 | +// } |
250 | 250 |
|
251 | 251 | export class GitDecorations {
|
252 | 252 |
|
@@ -287,7 +287,7 @@ export class GitDecorations {
|
287 | 287 | private onDidOpenRepository(repository: Repository): void {
|
288 | 288 | const providers = combinedDisposable([
|
289 | 289 | new GitDecorationProvider(repository),
|
290 |
| - new GitIncomingChangesFileDecorationProvider(repository) |
| 290 | + // new GitIncomingChangesFileDecorationProvider(repository) |
291 | 291 | ]);
|
292 | 292 |
|
293 | 293 | this.providers.set(repository, providers);
|
|
0 commit comments