Skip to content

Commit

Permalink
Fix bug with setting to open captured thoughts notes in new vs existi…
Browse files Browse the repository at this point in the history
…ng tabs
  • Loading branch information
zachmueller committed Sep 23, 2024
1 parent fafac39 commit bc72eb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,16 @@ export default class SpacedEverythingPlugin extends Plugin {
async openNewNote(newNoteFile: TFile) {
const { openCapturedThoughtInNewTab } = this.settings;

if (openCapturedThoughtInNewTab) {
await this.app.workspace.openLinkText(newNoteFile.path, newNoteFile.path, true, { active: true });
} else {
const leaf = this.app.workspace.getLeaf(true);
await leaf.openFile(newNoteFile);
if (!openCapturedThoughtInNewTab) {
const activeLeaf = this.app.workspace.activeLeaf;
if (activeLeaf) {
await activeLeaf.openFile(newNoteFile);
return;
} else {
new Notice('No active editor, opened note in new tab');
}
}
await this.app.workspace.openLinkText(newNoteFile.path, newNoteFile.path, true, { active: true });
}

async toggleNoteContexts(editor?: Editor, view?: MarkdownView) {
Expand Down
4 changes: 2 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ export class SpacedEverythingSettingTab extends PluginSettingTab {
);

new Setting(containerEl)
.setName('Open captured thought in new tab')
.setDesc('Open the newly created note in a new tab or the current tab')
.setName('Open in new tab')
.setDesc('Open the newly created note in a new tab. If turned off, captured thought note opens in currently active tab.')
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.openCapturedThoughtInNewTab)
Expand Down

0 comments on commit bc72eb3

Please sign in to comment.