From 9d8386ef7e3217615fbed08656ff079d36e18ad9 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Mon, 29 May 2017 23:36:17 +0300 Subject: [PATCH] IDEA-166464 Be able to merge usage from the same line in the "find in path" preview pane dialog --- .../com/intellij/find/impl/FindPopupPanel.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java index ea40febaeb69..41fe1f038dfa 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java @@ -824,6 +824,7 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider { final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation); Ref lastUsageFileRef = new Ref<>(); + Ref recentUsageRef = new Ref<>(); FindInProjectUtil.findUsages(myHelper.getModel().clone(), myProject, info -> { if(isCancelled()) { @@ -838,12 +839,26 @@ public class FindPopupPanel extends JBPanel implements FindUI, DataProvider { resultsFilesCount.incrementAndGet(); lastUsageFileRef.set(usageFile); } + final boolean merged; + Usage recent = recentUsageRef.get(); + UsageInfo2UsageAdapter recentAdapter = + recent != null && recent instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)recent : null; + UsageInfo2UsageAdapter currentAdapter = usage instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)usage : null; + if (currentAdapter != null && recentAdapter != null && recentAdapter.getFile().equals(usageFile) && recentAdapter.getLine() == currentAdapter.getLine()) { + merged = recentAdapter.merge(currentAdapter); + } else { + merged = false; + } + recentUsageRef.set(usage); + ApplicationManager.getApplication().invokeLater(() -> { if(isCancelled()) { return; } - model.addRow(new Object[]{usage}); + if (!merged) { + model.addRow(new Object[]{usage}); + } myCodePreviewComponent.setVisible(true); if (model.getRowCount() == 1 && myResultsPreviewTable.getModel() == model) { myResultsPreviewTable.setRowSelectionInterval(0, 0);