Skip to content

Commit

Permalink
hotfix: use openChatView instead of openNewChat because it's buggy
Browse files Browse the repository at this point in the history
  • Loading branch information
glowingjade committed Nov 2, 2024
1 parent 2eda8b3 commit b9c36eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class SmartCopilotPlugin extends Plugin {
this.addCommand({
id: 'open-new-chat',
name: 'Open chat',
callback: () => this.openNewChat(),
callback: () => this.openChatView(),
})

this.addCommand({
Expand Down Expand Up @@ -158,6 +158,9 @@ export default class SmartCopilotPlugin extends Plugin {
})
}

/**
* TODO: this is buggy, should fix first before using it
*/
async openNewChat() {
const view = this.app.workspace.getActiveViewOfType(MarkdownView)
const editor = view?.editor
Expand All @@ -175,6 +178,7 @@ export default class SmartCopilotPlugin extends Plugin {
} else {
const chatView = this.app.workspace.getLeavesOfType(CHAT_VIEW_TYPE)[0]
.view as ChatView
// sometimes, "openNewChat" not exists in chatView. don't know why
chatView.openNewChat(selectedBlock ?? undefined)
}
}
Expand Down

0 comments on commit b9c36eb

Please sign in to comment.