#108 - Removed Vim settings (now always on), and slightly changed the event handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { App, Modal, TFile } from 'obsidian'
|
||||
import ModalVault from './ModalVault.svelte'
|
||||
import ModalInFile from './ModalInFile.svelte'
|
||||
import {eventBus, EventNames, isInputComposition} from '../globals'
|
||||
import { eventBus, EventNames, isInputComposition } from '../globals'
|
||||
import { settings } from '../settings'
|
||||
|
||||
abstract class OmnisearchModal extends Modal {
|
||||
@@ -32,13 +32,13 @@ abstract class OmnisearchModal extends Modal {
|
||||
|
||||
// Ctrl+j/k
|
||||
for (const key of [
|
||||
{ k: 'j', dir: 'down' },
|
||||
{ k: 'k', dir: 'up' },
|
||||
{ k: 'J', dir: 'down' },
|
||||
{ k: 'K', dir: 'up' },
|
||||
] as const) {
|
||||
for (const modifier of ['Ctrl', 'Meta'] as const) {
|
||||
for (const modifier of ['Ctrl', 'Mod'] as const) {
|
||||
this.scope.register([modifier], key.k, e => {
|
||||
if (settings.CtrlJK && this.app.vault.getConfig('vimMode')) {
|
||||
e.preventDefault()
|
||||
if (this.app.vault.getConfig('vimMode')) {
|
||||
// e.preventDefault()
|
||||
eventBus.emit('arrow-' + key.dir)
|
||||
}
|
||||
})
|
||||
@@ -47,13 +47,13 @@ abstract class OmnisearchModal extends Modal {
|
||||
|
||||
// Ctrl+n/p
|
||||
for (const key of [
|
||||
{ k: 'n', dir: 'down' },
|
||||
{ k: 'p', dir: 'up' },
|
||||
{ k: 'N', dir: 'down' },
|
||||
{ k: 'P', dir: 'up' },
|
||||
] as const) {
|
||||
for (const modifier of ['Ctrl', 'Meta'] as const) {
|
||||
for (const modifier of ['Ctrl', 'Mod'] as const) {
|
||||
this.scope.register([modifier], key.k, e => {
|
||||
if (settings.CtrlNP && this.app.vault.getConfig('vimMode')) {
|
||||
e.preventDefault()
|
||||
if (this.app.vault.getConfig('vimMode')) {
|
||||
// e.preventDefault()
|
||||
eventBus.emit('arrow-' + key.dir)
|
||||
}
|
||||
})
|
||||
@@ -123,7 +123,7 @@ export class OmnisearchVaultModal extends OmnisearchModal {
|
||||
target: this.modalEl,
|
||||
props: {
|
||||
modal: this,
|
||||
previousQuery: query
|
||||
previousQuery: query,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ export interface OmnisearchSettings extends WeightingSettings {
|
||||
showCreateButton: boolean
|
||||
/** Re-execute the last query when opening Omnisearch */
|
||||
showPreviousQueryResults: boolean
|
||||
/** Vim mode shortcuts */
|
||||
CtrlJK: boolean
|
||||
/** Vim mode shortcuts */
|
||||
CtrlNP: boolean
|
||||
/** Key for the welcome message when Obsidian is updated. A message is only shown once. */
|
||||
welcomeMessage: string
|
||||
/** If a query returns 0 result, try again with more relax conditions */
|
||||
@@ -278,36 +274,6 @@ export class SettingsTab extends PluginSettingTab {
|
||||
.addSlider(cb => this.weightSlider(cb, 'weightH3'))
|
||||
|
||||
// #endregion Results Weighting
|
||||
|
||||
// #region Shortcuts
|
||||
|
||||
new Setting(containerEl).setName('Shortcuts').setHeading()
|
||||
|
||||
const ctrljk = new DocumentFragment()
|
||||
ctrljk.createSpan({}, span => {
|
||||
span.innerHTML =
|
||||
'Use <code>[Ctrl/Cmd]+j/k</code> to navigate up/down in the results, if Vim mode is enabled'
|
||||
})
|
||||
new Setting(containerEl).setName(ctrljk).addToggle(toggle =>
|
||||
toggle.setValue(settings.CtrlJK).onChange(async v => {
|
||||
settings.CtrlJK = v
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
|
||||
const ctrlnp = new DocumentFragment()
|
||||
ctrlnp.createSpan({}, span => {
|
||||
span.innerHTML =
|
||||
'Use <code>[Ctrl/Cmd]+j/k</code> to navigate up/down in the results, if Vim mode is enabled'
|
||||
})
|
||||
new Setting(containerEl).setName(ctrlnp).addToggle(toggle =>
|
||||
toggle.setValue(settings.CtrlNP).onChange(async v => {
|
||||
settings.CtrlNP = v
|
||||
await saveSettings(this.plugin)
|
||||
})
|
||||
)
|
||||
|
||||
// #endregion Shortcuts
|
||||
}
|
||||
|
||||
weightSlider(cb: SliderComponent, key: keyof WeightingSettings): void {
|
||||
@@ -349,9 +315,6 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
|
||||
weightH2: 1.3,
|
||||
weightH3: 1.1,
|
||||
|
||||
CtrlJK: true,
|
||||
CtrlNP: true,
|
||||
|
||||
// persistCache: false,
|
||||
|
||||
welcomeMessage: '',
|
||||
|
||||
Reference in New Issue
Block a user