✨ feat(vscode): 代码阅读侧栏可以按审查工单只看 PR 改过的文件:标题栏「选工单」列出看板「审查」列,选中后树里只剩改过的文件(M / A / D 着色),点开的是本机工作副本里 PR 最新的代码,没有就拉 PR 分支建一个,「显示全部」退出
This commit is contained in:
1 parent
c009187f6c
commit
8e2cdfaf17
18 files changed
+1053
-40
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import type { Disposable, Event, FileDecorationProvider, Uri } from 'vscode'
|
||||
import type { FileChange } from './changedFiles'
|
||||
import { EventEmitter, FileDecoration, ThemeColor } from 'vscode'
|
||||
import { CHANGE_STYLES } from './changedFiles'
|
||||
|
||||
/**
|
||||
* 审查工单时给 PR 改过的文件上色、挂 M / A / D 徽标,颜色和 VS Code 源代码管理一样;不审查时什么都不挂。
|
||||
* 挂在文件 Uri 上:侧栏的行、编辑器标签页上打开的这些文件都带着。
|
||||
*/
|
||||
export class ChangeDecorations implements FileDecorationProvider, Disposable {
|
||||
private readonly changed = new EventEmitter<Uri[]>()
|
||||
readonly onDidChangeFileDecorations: Event<Uri[]> = this.changed.event
|
||||
private changes = new Map<string, FileChange>()
|
||||
private uris: Uri[] = []
|
||||
|
||||
/** 换成这些文件的改动(空数组清掉),原来挂着的和新挂的都重画。 */
|
||||
show(files: readonly { uri: Uri, change: FileChange }[]): void {
|
||||
const before = this.uris
|
||||
this.changes = new Map(files.map(file => [file.uri.toString(), file.change]))
|
||||
this.uris = files.map(file => file.uri)
|
||||
this.changed.fire([...before, ...this.uris])
|
||||
}
|
||||
|
||||
provideFileDecoration(uri: Uri): FileDecoration | undefined {
|
||||
const change = this.changes.get(uri.toString())
|
||||
if (!change)
|
||||
return undefined
|
||||
const style = CHANGE_STYLES[change]
|
||||
return new FileDecoration(change, style.tooltip, new ThemeColor(style.color))
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.changed.dispose()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user