Skip to content

Commit

Permalink
resetting index
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushanand308 authored and agraef committed Jul 25, 2024
1 parent c8d2338 commit 11faf69
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
16 changes: 14 additions & 2 deletions pd/nw/dialog_prefs.html
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,14 @@
<span data-i18n="prefs.gui.browser.browser_init"></span>
</label>
</div>
<br/>
<label data-i18n="[title]prefs.gui.browser.reset_init_tt">
<input type="checkbox" id="reset_init" name="reset_init">
<span data-i18n="prefs.gui.browser.reset_init"></span>
</label>
<button type="button" onclick="reset_indexes()" data-i18n="[title]prefs.reset_index_tt">
<span data-i18n="prefs.reset_index"></span>
</button>
</div>

<div class="tab4">
Expand Down Expand Up @@ -535,10 +543,10 @@
<span data-i18n="prefs.ok"></span>
</button>
<button type="button" onClick="apply(false)" data-i18n="[title]prefs.apply_tt">
<span data-i18n="prefs.apply"></span>
<span data-i18n="prefs.apply"></span>
</button>
<button type="button" onClick="cancel()" data-i18n="[title]prefs.close_tt">
<span data-i18n="prefs.close"></span>
<span data-i18n="prefs.close"></span>
</button>
</div>
</div>
Expand All @@ -563,6 +571,10 @@
cancel();
}

function reset_indexes() {
pdgui.rebuild_index(get_bool_elem("reset_init"));
}

function gui_preset_change(elem) {
pdgui.skin.set(elem.value);
}
Expand Down
8 changes: 6 additions & 2 deletions pd/nw/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@
"browser_path": "help browser also searches the help path",
"browser_path_tt": "Also scan help patches in the user-defined help path for searchable keywords (slower)",
"browser_init": "prepare the help index at application start",
"browser_init_tt": "If checked, prepare the index for the help browser already when the application starts"
"browser_init_tt": "If checked, prepare the index for the help browser already when the application starts",
"reset_init": "clear completions",
"reset_init_tt": "If checked, clear the custom completions and arguments when resetting the index"
}
},
"audio": {
Expand Down Expand Up @@ -495,7 +497,9 @@
"cancel": "Cancel",
"cancel_tt": "Cancel updating the preferences",
"close": "Close",
"close_tt": "Close the preferences dialog"
"close_tt": "Close the preferences dialog",
"reset_index": "Reset indexes",
"reset_index_tt": "Reset the help and completion indexes"
},
"font": {
"prop": {
Expand Down
10 changes: 9 additions & 1 deletion pd/nw/pdgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,16 @@ exports.build_index = build_index;

// normally, this doesn't actually rebuild the index, it just clears it, so
// that it will be rebuilt the next time the help browser is opened
function rebuild_index()
function rebuild_index(clear_index = false)
{
index = init_elasticlunr();
index_started = index_done = false;

if (clear_index) {
completion_list = [];
completion_index = new fuse(completion_list,autocomplete_index_options);
}

try {
fs.unlink(expand_tilde(cache_name));
fs.unlink(expand_tilde(stamps_name));
Expand All @@ -609,6 +615,8 @@ function rebuild_index()
}
}

exports.rebuild_index = rebuild_index;

// this is called from the gui tab of the prefs dialog
function update_browser(doc_flag, path_flag, ac_flag, ac_prefix_flag, ac_relevance_flag)
{
Expand Down

0 comments on commit 11faf69

Please sign in to comment.