File tree Expand file tree Collapse file tree 4 files changed +9
-4
lines changed 
src/renderer/html_handlebars 
search/reasonable_search_index Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ pub fn create_files(
6969            // To reduce the size of the generated JSON by preventing all `"` characters to be 
7070            // escaped, we instead surround the string with much less common `'` character. 
7171            format ! ( 
72-                 "window.search = JSON.parse('{}');" , 
72+                 "window.search = Object.assign(window.search,  JSON.parse('{}') );" , 
7373                index. replace( "\\ " ,  "\\ \\ " ) . replace( "'" ,  "\\ '" ) 
7474            ) 
7575            . as_bytes ( ) , 
Original file line number Diff line number Diff line change 11// This tests basic search behavior.
22
3+ fail-on-js-error: true
34go-to: |DOC_PATH| + "index.html"
45
56define-function: (
@@ -41,6 +42,9 @@ press-key: 's'
4142wait-for-css-false: ("#search-wrapper", {"display": "none"})
4243// We ensure the search bar has the focus.
4344assert: "#searchbar:focus"
45+ // Pressing a key will therefore update the search input.
46+ press-key: 't'
47+ assert-text: ("#searchbar", "t")
4448
4549// Now we press `Escape` to ensure that the search input disappears again.
4650press-key: 'Escape'
Original file line number Diff line number Diff line change @@ -9,8 +9,9 @@ use std::path::{Path, PathBuf};
99fn  read_book_index ( root :  & Path )  -> serde_json:: Value  { 
1010    let  index = root. join ( "book/searchindex.js" ) ; 
1111    let  index = std:: fs:: read_to_string ( index) . unwrap ( ) ; 
12-     let  index = index. trim_start_matches ( "window.search = JSON.parse('" ) ; 
13-     let  index = index. trim_end_matches ( "');" ) ; 
12+     let  index =
13+         index. trim_start_matches ( "window.search = Object.assign(window.search, JSON.parse('" ) ; 
14+     let  index = index. trim_end_matches ( "'));" ) ; 
1415    // We need unescape the string as it's supposed to be an escaped JS string. 
1516    serde_json:: from_str ( & index. replace ( "\\ '" ,  "'" ) . replace ( "\\ \\ " ,  "\\ " ) ) . unwrap ( ) 
1617} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments