From 8bdd4cf3191c545119cd475c560fbcd10fd83e89 Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Wed, 8 Jan 2020 13:45:18 +0100 Subject: [PATCH] Make conflict marking optional --- scm-ui/ui-components/src/repos/DiffFile.tsx | 31 +++++++++++++-------- scm-ui/ui-components/src/repos/DiffTypes.ts | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/scm-ui/ui-components/src/repos/DiffFile.tsx b/scm-ui/ui-components/src/repos/DiffFile.tsx index 87174ad72d..cab227bbd5 100644 --- a/scm-ui/ui-components/src/repos/DiffFile.tsx +++ b/scm-ui/ui-components/src/repos/DiffFile.tsx @@ -86,7 +86,8 @@ const ModifiedDiffComponent = styled(DiffComponent)` class DiffFile extends React.Component { static defaultProps: Partial = { - defaultCollapse: false + defaultCollapse: false, + markConflicts: true }; constructor(props: Props) { @@ -173,17 +174,8 @@ class DiffFile extends React.Component { }; renderHunk = (hunk: HunkType, i: number) => { - let inConflict = false; - for (i = 0; i < hunk.changes.length; ++i) { - if (hunk.changes[i].content === "<<<<<<< HEAD") { - inConflict = true; - } - if (inConflict) { - hunk.changes[i].type = "conflict"; - } - if (hunk.changes[i].content.startsWith(">>>>>>>")) { - inConflict = false; - } + if (this.props.markConflicts) { + this.markConflicts(hunk); } return [ {this.createHunkHeader(hunk, i)}, @@ -196,6 +188,21 @@ class DiffFile extends React.Component { ]; }; + markConflicts = (hunk: HunkType) => { + let inConflict = false; + for (let i = 0; i < hunk.changes.length; ++i) { + if (hunk.changes[i].content === "<<<<<<< HEAD") { + inConflict = true; + } + if (inConflict) { + hunk.changes[i].type = "conflict"; + } + if (hunk.changes[i].content.startsWith(">>>>>>>")) { + inConflict = false; + } + } + }; + renderFileTitle = (file: File) => { if (file.oldPath !== file.newPath && (file.type === "copy" || file.type === "rename")) { return ( diff --git a/scm-ui/ui-components/src/repos/DiffTypes.ts b/scm-ui/ui-components/src/repos/DiffTypes.ts index 592ac7b6db..49e9785d29 100644 --- a/scm-ui/ui-components/src/repos/DiffTypes.ts +++ b/scm-ui/ui-components/src/repos/DiffTypes.ts @@ -75,4 +75,5 @@ export type DiffObjectProps = { fileControlFactory?: FileControlFactory; fileAnnotationFactory?: FileAnnotationFactory; annotationFactory?: AnnotationFactory; + markConflicts?: boolean; };