Skip to content

Commit

Permalink
Merge pull request #265 from iterative/add-new-decorations
Browse files Browse the repository at this point in the history
2/3 - Add new decorations
  • Loading branch information
mattseddon authored Apr 13, 2021
2 parents 71cfaa6 + d1c56e7 commit 30998f1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
39 changes: 32 additions & 7 deletions extension/src/DecorationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
EventEmitter,
FileDecorationProvider,
FileDecoration,
Uri
Uri,
ThemeColor
} from 'vscode'
import { isStringInEnum } from './util'

Expand All @@ -21,6 +22,30 @@ enum Status {
}

export class DecorationProvider implements FileDecorationProvider {
private static DecorationDeleted: FileDecoration = {
badge: 'D',
color: new ThemeColor('gitDecoration.deletedResourceForeground'),
tooltip: 'DVC deleted'
}

private static DecorationModified: FileDecoration = {
badge: 'M',
color: new ThemeColor('gitDecoration.modifiedResourceForeground'),
tooltip: 'DVC modified'
}

private static DecorationNew: FileDecoration = {
badge: 'A',
color: new ThemeColor('gitDecoration.addedResourceForeground'),
tooltip: 'DVC added'
}

private static DecorationNotInCache: FileDecoration = {
badge: 'NC',
color: new ThemeColor('gitDecoration.renamedResourceForeground'),
tooltip: 'DVC not in cache'
}

private static DecorationTracked: FileDecoration = {
tooltip: 'DVC tracked'
}
Expand Down Expand Up @@ -74,16 +99,16 @@ export class DecorationProvider implements FileDecorationProvider {

async provideFileDecoration(uri: Uri): Promise<FileDecoration | undefined> {
if (this.state.deleted?.has(uri.path)) {
return DecorationProvider.DecorationTracked
}
if (this.state.modified?.has(uri.path)) {
return DecorationProvider.DecorationTracked
return DecorationProvider.DecorationDeleted
}
if (this.state.new?.has(uri.path)) {
return DecorationProvider.DecorationTracked
return DecorationProvider.DecorationNew
}
if (this.state.notInCache?.has(uri.path)) {
return DecorationProvider.DecorationTracked
return DecorationProvider.DecorationNotInCache
}
if (this.state.modified?.has(uri.path)) {
return DecorationProvider.DecorationModified
}
if (this.state.tracked?.has(uri.path)) {
return DecorationProvider.DecorationTracked
Expand Down
1 change: 1 addition & 0 deletions extension/src/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { URI, Utils } from 'vscode-uri'
export const EventEmitter = jest.fn()
export const Extension = jest.fn()
export const extensions = jest.fn()
export const ThemeColor = jest.fn()
export const Terminal = jest.fn()
export const window = jest.fn()
export const workspace = {
Expand Down

0 comments on commit 30998f1

Please sign in to comment.