| author | Kris De Volder | 2012-01-24 19:44:11 (EST) |
|---|---|---|
| committer | John Arthorne | 2012-01-27 14:26:02 (EST) |
| commit | bc39b867e55372e8f6e76842d62d48caf0b6391a (patch) (side-by-side diff) | |
| tree | 22a3ce8d199883dbd44276e4b8b45da0e6fd4518 | |
| parent | 3df6cc8a8cbac40b4bbe214ac619e4c451030fe7 (diff) | |
| download | org.eclipse.orion.client-bc39b867e55372e8f6e76842d62d48caf0b6391a.zip org.eclipse.orion.client-bc39b867e55372e8f6e76842d62d48caf0b6391a.tar.gz org.eclipse.orion.client-bc39b867e55372e8f6e76842d62d48caf0b6391a.tar.bz2 | |
Bug 336277 - Show paths for files with same name on Open Resource
| -rw-r--r-- | bundles/org.eclipse.orion.client.core/web/orion/searchClient.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/searchClient.js b/bundles/org.eclipse.orion.client.core/web/orion/searchClient.js index 05ecff9..c220d2e 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/searchClient.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/searchClient.js @@ -144,6 +144,40 @@ define(['require', 'dojo', 'dijit', 'orion/auth', 'orion/util', 'orion/searchUti }, showSearchResult: function(resultsNode, query, excludeFile, generateHeading, onResultReady, hideSummaries, jsonData) { + + //Helper function to append a path String to the end of a search result dom node + var appendPath = (function() { + + //Map to track the names we have already seen. If the name is a key in the map, it means + //we have seen it already. Optionally, the value associated to the key may be a function' + //containing some deferred work we need to do if we see the same name again. + var namesSeenMap = {}; + + function doAppend(domElement, hit) { + var path = hit.Path; + path = path.substring(0, path.length-hit.Name.length-1); + domElement.appendChild(document.createTextNode(' - ' + path + ' ')); + } + + function appendPath(domElement, hit) { + var name = hit.Name; + if (namesSeenMap.hasOwnProperty(name)) { + //Seen the name before + doAppend(domElement, hit); + var deferred = namesSeenMap[name]; + if (typeof(deferred)==='function') { + //We have seen the name before, but prior element left some deferred processing + namesSeenMap[name] = null; + deferred(); + } + } else { + //Not seen before, so, if we see it again in future we must append the path + namesSeenMap[name] = function() { doAppend(domElement, hit); }; + } + } + return appendPath; + }()); //End of appendPath function + var foundValidHit = false; dojo.empty(resultsNode); var token = jsonData.responseHeader.params.q; @@ -174,6 +208,7 @@ define(['require', 'dojo', 'dijit', 'orion/auth', 'orion/util', 'orion/searchUti var loc = hit.Location; hitLink.setAttribute('href', require.toUrl("edit/edit.html") + "#" + loc); col.appendChild(hitLink); + appendPath(col, hit); if (!hideSummaries && jsonData.highlighting && jsonData.highlighting[hit.Id] && jsonData.highlighting[hit.Id].Text) { var highlightText = jsonData.highlighting[hit.Id].Text[0]; |

