|
58 | 58 | import org.eclipse.jface.resource.JFaceResources; |
59 | 59 | import org.eclipse.jface.text.BadLocationException; |
60 | 60 | import org.eclipse.jface.text.CursorLinePainter; |
| 61 | +import org.eclipse.jface.text.Document; |
61 | 62 | import org.eclipse.jface.text.IDocument; |
62 | 63 | import org.eclipse.jface.text.IRegion; |
63 | 64 | import org.eclipse.jface.text.source.CompositeRuler; |
@@ -1173,6 +1174,9 @@ private void refreshDetails() { |
1173 | 1174 | viewer.revealRange(rangeStart, rangeEnd - rangeStart); |
1174 | 1175 |
|
1175 | 1176 | var targetLineFirstMatch = getQuery().findFirst(document.get(item.getOffset(), contextLenght - (item.getOffset() - start))); |
| 1177 | + if (targetLineFirstMatch == null) { |
| 1178 | + return; // nothing to refresh |
| 1179 | + } |
1176 | 1180 | int targetLineFirstMatchStart = item.getOffset() + targetLineFirstMatch.getOffset(); |
1177 | 1181 | // sets caret position |
1178 | 1182 | viewer.setSelectedRange(targetLineFirstMatchStart, 0); |
@@ -1289,6 +1293,10 @@ public void refreshWidgets() { |
1289 | 1293 | //element is available in the list. |
1290 | 1294 | openButton.setEnabled(itemCount>0); |
1291 | 1295 | } |
| 1296 | + //Auto-select the first search result for preview to be shown. |
| 1297 | + if (itemCount >= 1 && list.getSelection().isEmpty()) { |
| 1298 | + list.getTable().select(0); |
| 1299 | + } |
1292 | 1300 | refreshDetails(); |
1293 | 1301 | } |
1294 | 1302 | } |
@@ -1484,6 +1492,14 @@ public void update(LineItem match) { |
1484 | 1492 | } else { |
1485 | 1493 | //The QuickTextSearcher is already active update the query |
1486 | 1494 | this.searcher.setQuery(newFilter, force); |
| 1495 | + if(newFilter.getPatternString().trim().isEmpty()) { |
| 1496 | + //When pattern is cleared, clear the preview section |
| 1497 | + viewer.setDocument(new Document("")); //$NON-NLS-1$ |
| 1498 | + if (lineNumberColumn != null) { |
| 1499 | + viewer.removeVerticalRulerColumn(lineNumberColumn); |
| 1500 | + viewer.addVerticalRulerColumn(lineNumberColumn); |
| 1501 | + } |
| 1502 | + } |
1487 | 1503 | } |
1488 | 1504 | if (progressJob!=null) { |
1489 | 1505 | progressJob.schedule(); |
|
0 commit comments