@@ -23,7 +23,7 @@ abstract class Command extends Disposable {
23
23
24
24
export class BlameCommand extends Command {
25
25
constructor ( private git : GitProvider , private blameController : GitBlameController ) {
26
- super ( Commands . ShowBlameHistory ) ;
26
+ super ( Commands . ShowBlame ) ;
27
27
}
28
28
29
29
execute ( uri ?: Uri , range ?: Range , sha ?: string ) {
@@ -44,204 +44,29 @@ export class BlameCommand extends Command {
44
44
}
45
45
}
46
46
47
- // export class BlameCommand extends Command {
48
- // // static Colors: Array<Array<number>> = [ [255, 152, 0], [255, 87, 34], [121, 85, 72], [158, 158, 158], [96, 125, 139], [244, 67, 54], [233, 30, 99], [156, 39, 176], [103, 58, 183] ];
49
- // // private _decorations: TextEditorDecorationType[] = [];
50
-
51
- // constructor(private git: GitProvider, private blameDecoration: TextEditorDecorationType, private highlightDecoration: TextEditorDecorationType) {
52
- // super(Commands.ShowBlameHistory);
53
-
54
- // // BlameCommand.Colors.forEach(c => {
55
- // // this._decorations.push(window.createTextEditorDecorationType({
56
- // // dark: {
57
- // // backgroundColor: `rgba(${c[0]}, ${c[1]}, ${c[2]}, 0.15)`,
58
- // // //gutterIconPath: context.asAbsolutePath('images/blame-dark.png'),
59
- // // overviewRulerColor: `rgba(${c[0]}, ${c[1]}, ${c[2]}, 0.75)`,
60
- // // },
61
- // // //light: {
62
- // // //backgroundColor: 'rgba(0, 0, 0, 0.15)',
63
- // // //gutterIconPath: context.asAbsolutePath('images/blame-light.png'),
64
- // // //overviewRulerColor: c //'rgba(0, 0, 0, 0.75)',
65
- // // // },
66
- // // // before: {
67
- // // // margin: '0 1em 0 0'
68
- // // // },
69
- // // // after: {
70
- // // // margin: '0 0 0 2em'
71
- // // // },
72
- // // //gutterIconSize: 'contain',
73
- // // overviewRulerLane: OverviewRulerLane.Right,
74
- // // //isWholeLine: true
75
- // // }));
76
- // // });
77
- // }
78
-
79
- // execute(uri?: Uri, range?: Range, position?: Position) {
80
- // const editor = window.activeTextEditor;
81
- // if (!editor) {
82
- // return;
83
- // }
84
-
85
- // editor.setDecorations(this.blameDecoration, []);
86
- // editor.setDecorations(this.highlightDecoration, []);
87
-
88
- // const highlightDecorationRanges: Array<Range> = [];
89
- // const blameDecorationOptions: Array<DecorationOptions> = [];
90
-
91
- // this.git.getBlameForRange(uri.path, range).then(blame => {
92
- // if (!blame.lines.length) return;
93
-
94
- // const commits = Array.from(blame.commits.values());
95
- // const recentCommit = commits.sort((a, b) => b.date.getTime() - a.date.getTime())[0];
96
-
97
- // return this.git.getCommitMessages(uri.path)
98
- // .then(msgs => {
99
- // commits.forEach(c => {
100
- // c.message = msgs.get(c.sha.substring(0, c.sha.length - 1));
101
- // });
102
-
103
- // blame.lines.forEach(l => {
104
- // if (l.sha === recentCommit.sha) {
105
- // highlightDecorationRanges.push(editor.document.validateRange(new Range(l.line, 0, l.line, 1000000)));
106
- // }
107
-
108
- // const c = blame.commits.get(l.sha);
109
- // blameDecorationOptions.push({
110
- // range: editor.document.validateRange(new Range(l.line, 0, l.line, 0)),
111
- // hoverMessage: `${c.sha}: ${c.message}\n${c.author}, ${moment(c.date).format('MMMM Do, YYYY hh:MM a')}`,
112
- // renderOptions: {
113
- // // dark: {
114
- // // backgroundColor: `rgba(255, 255, 255, ${alphas.get(l.sha)})`
115
- // // },
116
- // before: {
117
- // //border: '1px solid gray',
118
- // //color: 'rgb(128, 128, 128)',
119
- // contentText: `${l.sha}`,
120
- // // margin: '0 1em 0 0',
121
- // // width: '5em'
122
- // }
123
- // // after: {
124
- // // contentText: `${c.author}, ${moment(c.date).format('MMMM Do, YYYY hh:MM a')}`,
125
- // // //color: 'rbg(128, 128, 128)',
126
- // // margin: '0 0 0 2em'
127
- // // }
128
- // }
129
- // });
130
- // });
131
- // });
132
-
133
- // // Array.from(blame.commits.values()).forEach((c, i) => {
134
- // // if (i == 0) {
135
- // // highlightDecorationRanges = blame.lines
136
- // // .filter(l => l.sha === c.sha)
137
- // // .map(l => editor.document.validateRange(new Range(l.line, 0, l.line, 1000000)));
138
- // // }
139
-
140
- // // blameDecorationOptions.push(blame.lines
141
- // // .filter(l => l.sha === c.sha)
142
- // // .map(l => {
143
- // // return {
144
- // // range: editor.document.validateRange(new Range(l.line, 0, l.line, 6)),
145
- // // hoverMessage: `${c.author}\n${moment(c.date).format('MMMM Do, YYYY hh:MM a')}\n${l.sha}`,
146
- // // renderOptions: {
147
- // // // dark: {
148
- // // // backgroundColor: `rgba(255, 255, 255, ${alphas.get(l.sha)})`
149
- // // // },
150
- // // before: {
151
- // // //border: '1px solid gray',
152
- // // //color: 'rgb(128, 128, 128)',
153
- // // contentText: `${l.sha}`,
154
- // // // margin: '0 1em 0 0',
155
- // // // width: '5em'
156
- // // }
157
- // // // after: {
158
- // // // contentText: `${c.author}, ${moment(c.date).format('MMMM Do, YYYY hh:MM a')}`,
159
- // // // //color: 'rbg(128, 128, 128)',
160
- // // // margin: '0 0 0 2em'
161
- // // // }
162
- // // }
163
- // // };
164
- // // }));
165
- // // });
166
- // })
167
- // .then(() => {
168
- // editor.setDecorations(this.blameDecoration, blameDecorationOptions);
169
- // editor.setDecorations(this.highlightDecoration, highlightDecorationRanges);
170
- // });
171
-
172
- // // this._decorations.forEach(d => editor.setDecorations(d, []));
173
- // // this.git.getBlameForRange(uri.path, range).then(blame => {
174
- // // if (!blame.lines.length) return;
175
-
176
- // // Array.from(blame.commits.values()).forEach((c, i) => {
177
- // // editor.setDecorations(this._decorations[i], blame.lines.filter(l => l.sha === c.sha).map(l => {
178
- // // const commit = c; //blame.commits.get(l.sha);
179
- // // return {
180
- // // range: editor.document.validateRange(new Range(l.line, 0, l.line, 1000000)),
181
- // // hoverMessage: `${commit.author}\n${moment(commit.date).format('MMMM Do, YYYY hh:MM a')}\n${l.sha}`,
182
- // // renderOptions: {
183
- // // // dark: {
184
- // // // backgroundColor: `rgba(255, 255, 255, ${alphas.get(l.sha)})`
185
- // // // },
186
- // // before: {
187
- // // color: 'rgb(128, 128, 128)',
188
- // // contentText: `${l.sha}`,
189
- // // //border: '1px solid gray',
190
- // // width: '5em',
191
- // // margin: '0 1em 0 0'
192
- // // },
193
- // // after: {
194
- // // contentText: `${commit.author}, ${moment(commit.date).format('MMMM Do, YYYY hh:MM a')}`,
195
- // // //color: 'rbg(128, 128, 128)',
196
- // // margin: '0 0 0 2em'
197
- // // }
198
- // // }
199
- // // };
200
- // // }));
201
- // // });
202
-
203
- // // //this.git.getCommitMessage(data.sha).then(msg => {
204
- // // // editor.setDecorations(this._blameDecoration, blame.lines.map(l => {
205
- // // // const commit = blame.commits.get(l.sha);
206
- // // // return {
207
- // // // range: editor.document.validateRange(new Range(l.line, 0, l.line, 1000000)),
208
- // // // hoverMessage: `${commit.author}\n${moment(commit.date).format('MMMM Do, YYYY hh:MM a')}\n${l.sha}`,
209
- // // // renderOptions: {
210
- // // // // dark: {
211
- // // // // backgroundColor: `rgba(255, 255, 255, ${alphas.get(l.sha)})`
212
- // // // // },
213
- // // // before: {
214
- // // // contentText: `${l.sha}`,
215
- // // // margin: '0 0 0 -10px'
216
- // // // },
217
- // // // after: {
218
- // // // contentText: `${l.sha}`,
219
- // // // color: 'rbg(128, 128, 128)',
220
- // // // margin: '0 20px 0 0'
221
- // // // }
222
- // // // }
223
- // // // };
224
- // // // }));
225
- // // // })
226
- // // });
227
-
228
- // // // If the command is executed manually -- treat it as a click on the root lens (i.e. show blame for the whole file)
229
- // // if (!uri) {
230
- // // const doc = window.activeTextEditor && window.activeTextEditor.document;
231
- // // if (doc) {
232
- // // uri = doc.uri;
233
- // // range = doc.validateRange(new Range(0, 0, 1000000, 1000000));
234
- // // position = doc.validateRange(new Range(0, 0, 0, 1000000)).start;
235
- // // }
47
+ export class HistoryCommand extends Command {
48
+ constructor ( private git : GitProvider ) {
49
+ super ( Commands . ShowHistory ) ;
50
+ }
236
51
237
- // // if (!uri) return;
238
- // // }
52
+ execute ( uri ?: Uri , range ?: Range , position ?: Position ) {
53
+ // If the command is executed manually -- treat it as a click on the root lens (i.e. show blame for the whole file)
54
+ if ( ! uri ) {
55
+ const doc = window . activeTextEditor && window . activeTextEditor . document ;
56
+ if ( doc ) {
57
+ uri = doc . uri ;
58
+ range = doc . validateRange ( new Range ( 0 , 0 , 1000000 , 1000000 ) ) ;
59
+ position = doc . validateRange ( new Range ( 0 , 0 , 0 , 1000000 ) ) . start ;
60
+ }
61
+
62
+ if ( ! uri ) return ;
63
+ }
239
64
240
- // // return this.git.getBlameLocations(uri.path, range).then(locations => {
241
- // // return commands.executeCommand(VsCodeCommands.ShowReferences, uri, position, locations);
242
- // / / });
243
- // }
244
- // }
65
+ return this . git . getBlameLocations ( uri . path , range ) . then ( locations => {
66
+ return commands . executeCommand ( VsCodeCommands . ShowReferences , uri , position , locations ) ;
67
+ } ) ;
68
+ }
69
+ }
245
70
246
71
export class DiffWithPreviousCommand extends Command {
247
72
constructor ( private git : GitProvider ) {
0 commit comments