Skip to content

Commit

Permalink
Fix Component#registerScopeEvent removed from the API
Browse files Browse the repository at this point in the history
Signed-off-by: William So <polyipseity@gmail.com>
  • Loading branch information
polyipseity committed May 5, 2023
1 parent d5c8168 commit e203c80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sources/terminal/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
printError,
printMalformedData,
readStateCollabratively,
registerKey,
saveFileAs,
updateDisplayText,
useSettings,
Expand Down Expand Up @@ -484,15 +485,17 @@ export class TerminalView extends ItemView {
keymap.pushScope(focusedScope)
}

this.registerScopeEvent(scope.register(
this.register(registerKey(
scope,
cloneAsWritable(TerminalView.modifiers),
"`",
event => {
this.#emulator?.terminal.focus()
consumeEvent(event)
},
))
this.registerScopeEvent(focusedScope.register(
this.register(registerKey(
focusedScope,
cloneAsWritable(TerminalView.modifiers),
"`",
event => {
Expand All @@ -504,15 +507,17 @@ export class TerminalView extends ItemView {
consumeEvent(event)
},
))
this.registerScopeEvent(focusedScope.register(
this.register(registerKey(
focusedScope,
cloneAsWritable(TerminalView.modifiers),
"f",
event => {
this.startFind()
consumeEvent(event)
},
))
this.registerScopeEvent(focusedScope.register(
this.register(registerKey(
focusedScope,
cloneAsWritable(TerminalView.modifiers),
"k",
event => {
Expand Down
9 changes: 9 additions & 0 deletions sources/utils/obsidian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Notice,
Plugin,
type PluginManifest,
type Scope,
Setting,
View,
addIcon as addIcon0,
Expand Down Expand Up @@ -377,6 +378,14 @@ export function printError(
)
}

export function registerKey(
self: Scope,
...args: Parameters<Scope["register"]>
): () => void {
const handle = self.register(...args)
return () => { self.unregister(handle) }
}

export function readStateCollabratively(
implType: string,
state: unknown,
Expand Down

0 comments on commit e203c80

Please sign in to comment.