]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12111 Fix source misalignment
authorJeremy Davis <jeremy.davis@sonarsource.com>
Thu, 16 May 2019 13:09:48 +0000 (15:09 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 23 May 2019 18:21:10 +0000 (20:21 +0200)
server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetViewer.tsx
server/sonar-web/src/main/js/apps/issues/styles.css
server/sonar-web/src/main/js/components/SourceViewer/styles.css

index d989e9f5a4ad53d92660659956314aececc8ad43..0a0441159804191e001f617eb1e2b03fbc2f85c2 100644 (file)
@@ -214,6 +214,7 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
   };
 
   renderLine({
+    displayDuplications,
     index,
     issuesForLine,
     issueLocations,
@@ -222,6 +223,7 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
     symbols,
     verticalBuffer
   }: {
+    displayDuplications: boolean;
     index: number;
     issuesForLine: T.Issue[];
     issueLocations: T.LinearIssueLocation[];
@@ -245,7 +247,7 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
         branchLike={undefined}
         displayAllIssues={false}
         displayCoverage={true}
-        displayDuplications={!!line.duplicated}
+        displayDuplications={displayDuplications}
         displayIssues={!isSinkLine || issuesForLine.length > 1}
         displayLocationMarkers={true}
         duplications={lineDuplications}
@@ -318,6 +320,8 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
       ? Math.max(0, LINES_BELOW_LAST - (bottomLine - lowestVisibleIssue))
       : 0;
 
+    const displayDuplications = snippet.some(s => !!s.duplicated);
+
     return (
       <div className="source-viewer-code snippet" key={index}>
         {snippet[0].line > 1 && (
@@ -333,6 +337,7 @@ export default class ComponentSourceSnippetViewer extends React.PureComponent<Pr
           <tbody>
             {snippet.map((line, index) =>
               this.renderLine({
+                displayDuplications,
                 index,
                 issuesForLine: issuesByLine[line.line] || [],
                 issueLocations: locationsByLine[line.line] || [],
index 85d3c2e346044b06823adbc44655f7f5eaf2085f..0aa8aeecd544d9d91fcb9e82290ae5a87e83dd79 100644 (file)
   }
 }
 
+.issue-location {
+  display: inline-block;
+  vertical-align: top;
+  line-height: 18px;
+  height: 18px;
+  box-sizing: border-box;
+  background-color: var(--issueBgColor);
+  transition: background-color 0.3s ease;
+}
+
 .issues-workspace-list-component {
   padding: 10px 10px 6px;
 }
index db5f812a00b7804b1386a022d1eba815a33ba8cc..d3be853668035486dbdc52247fa9c8026085c8fe 100644 (file)
   user-select: text;
 }
 
-.issue-location {
-  display: inline-block;
-  vertical-align: top;
-  line-height: 18px;
-  height: 18px;
-  box-sizing: border-box;
-  background-color: var(--issueBgColor);
-  transition: background-color 0.3s ease;
-}
-
 .issue-location.highlighted {
   border-color: #e1e1f2;
   background-color: #e1e1f2;