Skip to content

Commit 1be3e82

Browse files
author
guqiankun
committed
chore: 增加全局contextkey
1 parent 88e778d commit 1be3e82

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

packages/acr/src/modules/diff-folding/diff-folding.contribution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from '@opensumi/ide-core-browser';
2323
import { Domain } from '@opensumi/ide-core-common/lib/di-helper';
2424
import { WorkbenchEditorService } from '@opensumi/ide-editor';
25-
import { MiscCommands, MISC_IS_EXPAND_RAW_KEY } from '.';
25+
import { MiscCommands, MISC_IS_EXPAND_RAW_KEY, MISC_IS_DIFF_DATA } from '.';
2626
import { AntcodeDiffFoldingService } from './diff-folding.service';
2727
import { sleep, generateRange } from './utils';
2828
import { DiffFoldingWidgetService } from './zone-widget/widget.service';
@@ -68,14 +68,14 @@ export class DiffFoldingContribution extends WithEventBus implements CommandCont
6868
private disposeColl = new DisposableCollection();
6969

7070
private readonly miscIsExpand: IContextKey<boolean>;
71+
private readonly isDiffData: IContextKey<boolean>;
7172

7273
private currentURI: URI | undefined;
7374

74-
private isDiffData = false;
75-
7675
constructor() {
7776
super();
7877
this.miscIsExpand = MISC_IS_EXPAND_RAW_KEY.bind(this.globalContextKeyService);
78+
this.isDiffData = MISC_IS_DIFF_DATA.bind(this.globalContextKeyService);
7979
this.antcodeDiffFoldingService.currentRangeModel.setCurrentRangeMap([], 'original');
8080
this.antcodeDiffFoldingService.currentRangeModel.setCurrentRangeMap([], 'modified');
8181
}
@@ -120,9 +120,9 @@ export class DiffFoldingContribution extends WithEventBus implements CommandCont
120120
this.gitDocContentProvider.diffData.has(originalUri.toString()) &&
121121
this.gitDocContentProvider.diffData.has(modifiedUri.toString())
122122
) {
123-
this.isDiffData = true;
123+
this.isDiffData.set(true);
124124
} else {
125-
this.isDiffData = false;
125+
this.isDiffData.set(false);
126126
}
127127
// diff 数据折叠
128128
if (!this.preferenceService.get('acr.foldingEnabled') && !this.isDiffData) return;

packages/acr/src/modules/diff-folding/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export class MiscCommands {
2323
export const MISC_IS_EXPAND = 'misc.isExpand';
2424
export const MISC_IS_EXPAND_RAW_KEY = new RawContextKey<boolean>(MISC_IS_EXPAND, false);
2525

26+
export const IS_DIFF_DATA = 'misc.isDiffData';
27+
export const MISC_IS_DIFF_DATA = new RawContextKey<boolean>(IS_DIFF_DATA, false);
28+
2629
export interface IConverDiffByGit {
2730
content: string;
2831
type: '-' | '+' | null;

packages/acr/src/modules/merge-request/changes-tree/changes-tree.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class ChangesTreeContribution
176176
},
177177
iconClass: getIcon('file-expand'),
178178
group: 'navigation',
179-
when: 'isInDiffEditor && config.acr.foldingEnabled',
179+
when: 'isInDiffEditor && config.acr.foldingEnabled && !misc.isDiffData',
180180
toggledWhen: 'config.misc.isExpand',
181181
order: 5,
182182
});

packages/acr/src/modules/open-change-files/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,10 @@ export class OpenChangeFilesService extends Disposable {
224224
async fetchDiff(path: string) {
225225
// 如果没有 diff 信息,则去请求
226226
const changeDiff = this.antcodeService.pullRequestChangeList.find((changeDiff) => {
227-
if (changeDiff.newPath === path) {
228-
return true;
229-
} else if (changeDiff.newPath !== changeDiff.oldPath && changeDiff.oldPath === path) {
230-
// 重命名文件
231-
return true;
232-
} else {
233-
return false;
234-
}
227+
return (
228+
changeDiff.newPath === path ||
229+
(changeDiff.newPath !== changeDiff.oldPath && changeDiff.oldPath === path)
230+
);
235231
});
236232
// @ts-ignore
237233
if (!changeDiff.diff) {

0 commit comments

Comments
 (0)