#70 - Correctly toggling and saving settings.showContext
This commit is contained in:
@@ -16,17 +16,12 @@ export interface OmnisearchSettings extends WeightingSettings {
|
||||
showIndexingNotices: boolean
|
||||
ribbonIcon: boolean
|
||||
showShortName: boolean
|
||||
showContext: SearchContextType
|
||||
showContext: boolean
|
||||
CtrlJK: boolean
|
||||
CtrlNP: boolean
|
||||
storeIndexInFile: boolean
|
||||
}
|
||||
|
||||
export enum SearchContextType {
|
||||
None,
|
||||
Simple,
|
||||
}
|
||||
|
||||
export class SettingsTab extends PluginSettingTab {
|
||||
plugin: OmnisearchPlugin
|
||||
|
||||
@@ -131,6 +126,25 @@ export class SettingsTab extends PluginSettingTab {
|
||||
})
|
||||
)
|
||||
|
||||
// Show Context
|
||||
new Setting(containerEl)
|
||||
.setName('Show context')
|
||||
.setDesc(
|
||||
'Shows the part of the note that matches the search. Disable this to only show filenames in results.'
|
||||
)
|
||||
.addToggle(toggle =>
|
||||
toggle.setValue(get(settings).showContext).onChange(async v => {
|
||||
settings.update(s => {
|
||||
s.showContext = v
|
||||
return s
|
||||
})
|
||||
await saveSettings(this.plugin)
|
||||
if (v) {
|
||||
this.plugin.addRibbonButton()
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
// Show notices
|
||||
new Setting(containerEl)
|
||||
.setName('Show indexing notices')
|
||||
@@ -243,7 +257,7 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
||||
showIndexingNotices: false,
|
||||
showShortName: false,
|
||||
ribbonIcon: true,
|
||||
showContext: SearchContextType.Simple,
|
||||
showContext: true,
|
||||
|
||||
weightBasename: 2,
|
||||
weightH1: 1.5,
|
||||
|
||||
Reference in New Issue
Block a user