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(
69
69
// To reduce the size of the generated JSON by preventing all `"` characters to be
70
70
// escaped, we instead surround the string with much less common `'` character.
71
71
format ! (
72
- "window.search = JSON.parse('{}');" ,
72
+ "window.search = Object.assign(window.search, JSON.parse('{}') );" ,
73
73
index. replace( "\\ " , "\\ \\ " ) . replace( "'" , "\\ '" )
74
74
)
75
75
. as_bytes ( ) ,
Original file line number Diff line number Diff line change 1
1
// This tests basic search behavior.
2
2
3
+ fail-on-js-error: true
3
4
go-to: |DOC_PATH| + "index.html"
4
5
5
6
define-function: (
@@ -41,6 +42,9 @@ press-key: 's'
41
42
wait-for-css-false: ("#search-wrapper", {"display": "none"})
42
43
// We ensure the search bar has the focus.
43
44
assert: "#searchbar:focus"
45
+ // Pressing a key will therefore update the search input.
46
+ press-key: 't'
47
+ assert-text: ("#searchbar", "t")
44
48
45
49
// Now we press `Escape` to ensure that the search input disappears again.
46
50
press-key: 'Escape'
Original file line number Diff line number Diff line change @@ -9,8 +9,9 @@ use std::path::{Path, PathBuf};
9
9
fn read_book_index ( root : & Path ) -> serde_json:: Value {
10
10
let index = root. join ( "book/searchindex.js" ) ;
11
11
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 ( "'));" ) ;
14
15
// We need unescape the string as it's supposed to be an escaped JS string.
15
16
serde_json:: from_str ( & index. replace ( "\\ '" , "'" ) . replace ( "\\ \\ " , "\\ " ) ) . unwrap ( )
16
17
}
You can’t perform that action at this time.
0 commit comments