]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3101 "Duplications" tab shows incorrect lines
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 16 Dec 2011 13:12:44 +0000 (14:12 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 16 Dec 2011 13:12:44 +0000 (14:12 +0100)
sonar-server/src/main/webapp/WEB-INF/app/views/resource/_duplications_source_snippet.html.erb

index f16330e4fe41abe8e5a3c2f4149e248a20345b1b..02b4460950f6a085f865b46922abf1e555a9b17f 100644 (file)
@@ -1,48 +1,48 @@
 <div class="<%= 'expanded' if to_line == from_line + lines_count -%>">
-    <%
-      if external
-        parent_project = resource.project
-    %>
-      <p>
-        <%= qualifier_icon(parent_project) -%>
-        <%= link_to_resource(parent_project, parent_project.path_name, {:dashboard => true}) -%>
-        &nbsp;&nbsp;
-        <%= qualifier_icon(resource) -%>
+  <%
+     if external
+       parent_project = resource.project
+  %>
+    <p>
+      <%= qualifier_icon(parent_project) -%>
+      <%= link_to_resource(parent_project, parent_project.path_name, {:dashboard => true}) -%>
+      &nbsp;&nbsp;
+      <%= qualifier_icon(resource) -%>
+      <%= link_to_resource(resource, resource.name(true), {:line => from_line}) -%>
+      <span id="duplLoading-<%= group_index -%>"></span>
+    </p>
+  <%
+     else
+  %>
+    <p>
+      <%= qualifier_icon(resource) -%>
+      <% if resource == original_resource %>
+        <%= resource.name(true) -%>
+      <% else %>
         <%= link_to_resource(resource, resource.name(true), {:line => from_line}) -%>
-        <span id="duplLoading-<%= group_index -%>"></span>
-      </p>
-    <%
-      else
-    %>
-     <p>
-       <%= qualifier_icon(resource) -%>
-       <% if resource == original_resource %>
-         <%= resource.name(true) -%>
-       <% else %>
-         <%= link_to_resource(resource, resource.name(true), {:line => from_line}) -%>
-       <% end %>
-       <span id="duplLoading-<%= group_index -%>"></span>
-     </p>
-    <% end %>
+      <% end %>
+      <span id="duplLoading-<%= group_index -%>"></span>
+    </p>
+  <% end %>
 
   <%= snapshot_source_to_html(resource.last_snapshot, {:line_range => from_line..to_line}) -%>
-  
+
   <% if lines_count > 5 %>
-  <p class="small">
-    <% 
-      if to_line < from_line + lines_count
-        link_text =  message('duplications.expand')
-        to_line = from_line + lines_count
-      else
-        link_text =  message('duplications.collapse')
-        to_line = from_line + 5
-      end 
-    %>
-    <%= link_to_remote link_text, 
-                       :url => {:action => :show_duplication_snippet, :params => {:id => resource.id, :original_resource_id => original_resource.id, :from_line => from_line, :to_line => to_line, :lines_count => lines_count, :group_index => group_index}},
-                       :update => "source-#{group_index}",
-                       :before => "$('expanding-#{group_index}').addClassName('loading')" -%>
-    <span id="expanding-<%= group_index -%>"></span>
-  </p>
+    <p class="small">
+      <%
+         if to_line < from_line + lines_count
+           link_text = message('duplications.expand')
+           to_line = from_line + lines_count - 1
+         else
+           link_text = message('duplications.collapse')
+           to_line = from_line + 5
+         end
+      %>
+      <%= link_to_remote link_text,
+                         :url => {:action => :show_duplication_snippet, :params => {:id => resource.id, :original_resource_id => original_resource.id, :from_line => from_line, :to_line => to_line, :lines_count => lines_count, :group_index => group_index}},
+                         :update => "source-#{group_index}",
+                         :before => "$('expanding-#{group_index}').addClassName('loading')" -%>
+      <span id="expanding-<%= group_index -%>"></span>
+    </p>
   <% end %>
 </div>
\ No newline at end of file