mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Multi quick diff polish (#174584)
Part of https://github.com/microsoft/vscode/issues/169012
This commit is contained in:
parent
d4b10110da
commit
6da385b3a3
|
@ -15,6 +15,7 @@
|
|||
"contribEditSessions",
|
||||
"contribViewsWelcome",
|
||||
"editSessionIdentityProvider",
|
||||
"quickDiffProvider",
|
||||
"scmActionButton",
|
||||
"scmSelectedProvider",
|
||||
"scmValidation",
|
||||
|
|
|
@ -960,6 +960,13 @@ export class Repository implements Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick diff label
|
||||
*/
|
||||
get label(): string {
|
||||
return l10n.t('Git local working changes');
|
||||
}
|
||||
|
||||
provideOriginalResource(uri: Uri): Uri | undefined {
|
||||
if (uri.scheme !== 'file') {
|
||||
return;
|
||||
|
|
|
@ -158,7 +158,11 @@ class MainThreadSCMProvider implements ISCMProvider, QuickDiffProvider {
|
|||
}
|
||||
|
||||
if (features.hasQuickDiffProvider && !this._quickDiff) {
|
||||
this._quickDiff = this._quickDiffService.addQuickDiffProvider(this);
|
||||
this._quickDiff = this._quickDiffService.addQuickDiffProvider({
|
||||
label: features.quickDiffLabel ?? this.label,
|
||||
rootUri: this.rootUri,
|
||||
getOriginalResource: (uri: URI) => this.getOriginalResource(uri)
|
||||
});
|
||||
} else if (features.hasQuickDiffProvider === false && this._quickDiff) {
|
||||
this._quickDiff.dispose();
|
||||
this._quickDiff = undefined;
|
||||
|
|
|
@ -1179,6 +1179,7 @@ export interface MainThreadExtensionServiceShape extends IDisposable {
|
|||
|
||||
export interface SCMProviderFeatures {
|
||||
hasQuickDiffProvider?: boolean;
|
||||
quickDiffLabel?: string;
|
||||
count?: number;
|
||||
commitTemplate?: string;
|
||||
acceptInputCommand?: languages.Command;
|
||||
|
|
|
@ -488,7 +488,10 @@ class ExtHostSourceControl implements vscode.SourceControl {
|
|||
|
||||
set quickDiffProvider(quickDiffProvider: vscode.QuickDiffProvider | undefined) {
|
||||
this._quickDiffProvider = quickDiffProvider;
|
||||
this.#proxy.$updateSourceControl(this.handle, { hasQuickDiffProvider: !!quickDiffProvider });
|
||||
if (quickDiffProvider?.label) {
|
||||
checkProposedApiEnabled(this._extension, 'quickDiffProvider');
|
||||
}
|
||||
this.#proxy.$updateSourceControl(this.handle, { hasQuickDiffProvider: !!quickDiffProvider, quickDiffLabel: quickDiffProvider?.label });
|
||||
}
|
||||
|
||||
private _commitTemplate: string | undefined = undefined;
|
||||
|
|
|
@ -235,7 +235,6 @@ class DirtyDiffWidget extends PeekViewWidget {
|
|||
const change = labeledChange.change;
|
||||
this._index = index;
|
||||
this._provider = labeledChange.label;
|
||||
const previousVisibleRange = this.visibleRange;
|
||||
this.change = change;
|
||||
|
||||
const originalModel = this.model.original;
|
||||
|
@ -248,7 +247,7 @@ class DirtyDiffWidget extends PeekViewWidget {
|
|||
|
||||
// TODO@joao TODO@alex need this setTimeout probably because the
|
||||
// non-side-by-side diff still hasn't created the view zones
|
||||
onFirstDiffUpdate(() => setTimeout(() => (usePosition || !previousVisibleRange) ? this.revealChange(change) : this.revealLines(previousVisibleRange), 0));
|
||||
onFirstDiffUpdate(() => setTimeout(() => this.revealChange(change), 0));
|
||||
|
||||
const diffEditorModel = this.model.getDiffEditorModel(labeledChange.uri.toString());
|
||||
if (!diffEditorModel) {
|
||||
|
@ -437,10 +436,6 @@ class DirtyDiffWidget extends PeekViewWidget {
|
|||
this.diffEditor.revealLinesInCenter(start, end, ScrollType.Immediate);
|
||||
}
|
||||
|
||||
private revealLines(range: Range): void {
|
||||
this.diffEditor.revealLinesInCenter(range.startLineNumber, range.endLineNumber, ScrollType.Immediate);
|
||||
}
|
||||
|
||||
private _applyTheme(theme: IColorTheme) {
|
||||
const borderColor = theme.getColor(peekViewBorder) || Color.transparent;
|
||||
this.style({
|
||||
|
|
|
@ -10,4 +10,8 @@ declare module 'vscode' {
|
|||
export namespace window {
|
||||
export function registerQuickDiffProvider(selector: DocumentSelector, quickDiffProvider: QuickDiffProvider, label: string, rootUri?: Uri): Disposable;
|
||||
}
|
||||
|
||||
interface QuickDiffProvider {
|
||||
label?: string;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue