@@ -64,7 +64,7 @@ const _displayItem = (item, searchTerms, highlightTerms) => {
6464 const showSearchSummary = DOCUMENTATION_OPTIONS . SHOW_SEARCH_SUMMARY ;
6565 const contentRoot = document . documentElement . dataset . content_root ;
6666
67- const [ docName , title , anchor , descr , score , _filename ] = item ;
67+ const [ docName , title , _isDocumentTitle , anchor , descr , score ] = item ;
6868
6969 let listItem = document . createElement ( "li" ) ;
7070 let requestUrl ;
@@ -314,6 +314,7 @@ const Search = {
314314 results . push ( [
315315 docNames [ file ] ,
316316 isDocumentTitle ? title : `${ titles [ file ] } > ${ title } ` ,
317+ isDocumentTitle ,
317318 anchor ,
318319 null ,
319320 score ,
@@ -331,6 +332,7 @@ const Search = {
331332 results . push ( [
332333 docNames [ file ] ,
333334 titles [ file ] ,
335+ false ,
334336 id ? "#" + id : "" ,
335337 null ,
336338 score ,
@@ -355,8 +357,8 @@ const Search = {
355357 // display function below uses pop() to retrieve items) and then
356358 // alphabetically
357359 results . sort ( ( a , b ) => {
358- const leftScore = a [ 4 ] ;
359- const rightScore = b [ 4 ] ;
360+ const leftScore = a [ 5 ] ;
361+ const rightScore = b [ 5 ] ;
360362 if ( leftScore === rightScore ) {
361363 // same score: sort alphabetically
362364 const leftTitle = a [ 1 ] . toLowerCase ( ) ;
@@ -371,8 +373,11 @@ const Search = {
371373 // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept
372374 let seen = new Set ( ) ;
373375 results = results . reverse ( ) . reduce ( ( acc , result ) => {
374- // de-duplicate on file, title, and description
375- let resultStr = result . slice ( 0 , 2 ) . concat ( result [ 3 ] ) . map ( v => String ( v ) ) . join ( ',' ) ;
376+ // de-duplicate on file, title, description, and (if not the title section) anchor
377+ // we omit the anchor for the title section as otherwise we'll get two entries for the
378+ // entire document
379+ let [ docname , title , isDocumentTitle , anchor , descr , score , filename ] = result ;
380+ let resultStr = [ docname , title , isDocumentTitle ? '' : anchor , descr ] . map ( v => String ( v ) ) . join ( ',' ) ;
376381 if ( ! seen . has ( resultStr ) ) {
377382 acc . push ( result ) ;
378383 seen . add ( resultStr ) ;
@@ -446,6 +451,7 @@ const Search = {
446451 results . push ( [
447452 docNames [ match [ 0 ] ] ,
448453 fullname ,
454+ false ,
449455 "#" + anchor ,
450456 descr ,
451457 score ,
@@ -557,6 +563,7 @@ const Search = {
557563 results . push ( [
558564 docNames [ file ] ,
559565 titles [ file ] ,
566+ false ,
560567 "" ,
561568 null ,
562569 score ,
0 commit comments