Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Path Title plugin #786

Merged
merged 2 commits into from
Apr 5, 2022
Merged

Add Path Title plugin #786

merged 2 commits into from
Apr 5, 2022

Conversation

jdeal
Copy link
Contributor

@jdeal jdeal commented Feb 13, 2022

I am submitting a new Community Plugin

Repo URL

Link to my plugin: https://github.com/jdeal/obsidian-path-title-plugin

Release Checklist

  • I have tested the plugin on
    • Windows
    • macOS
    • Linux
    • Android (if applicable)
    • iOS (if applicable)
  • My GitHub release contains all required files
    • main.js
    • manifest.json
    • styles.css (optional)
  • GitHub release name matches the exact version number specified in my manifest.json (Note: Use the exact version number, don't include a prefix v)
  • The id in my manifest.json matches the id in the community-plugins.json file.
  • My README.md describes the plugin's purpose and provides clear usage instructions.
  • I have read the tips in https://github.com/obsidianmd/obsidian-releases/blob/master/plugin-review.md and have self-reviewed my plugin to avoid these common pitfalls.
  • I have added a license in the LICENSE file.
  • My project respects and is compatible with the original license of any code from other plugins that I'm using.
    I have given proper attribution to these other projects in my README.md.

@lishid
Copy link
Collaborator

lishid commented Feb 24, 2022

https://github.com/jdeal/obsidian-path-title-plugin/blob/948fc84216ae1b016daeae44b893dafaa3c0ba3d/src/plugin.ts#L53
The rename event can sometimes be called many times consecutively (when renaming a folder with lots of subfolders) - you should debounce the setPaneTitles function.

https://github.com/jdeal/obsidian-path-title-plugin/blob/948fc84216ae1b016daeae44b893dafaa3c0ba3d/src/plugin.ts#L144
This should be reused - put it in a variable and reference it again.

I also suggest you detaching the element instead of just setting its display to none.

https://github.com/jdeal/obsidian-path-title-plugin/blob/948fc84216ae1b016daeae44b893dafaa3c0ba3d/src/plugin.ts#L166
Here you are not removing the elements you added (.path-title-plugin-path-title-container).

https://github.com/jdeal/obsidian-path-title-plugin/blob/948fc84216ae1b016daeae44b893dafaa3c0ba3d/src/plugin.ts#L61
I feel like the execution complexity here doesn't warrant the extra effort for memoizing path replacements - if you update paths on a reasonable debounce I recommend removing the memoization and just call the function for every file view.

jdeal added a commit to jdeal/obsidian-path-title-plugin that referenced this pull request Mar 27, 2022
@jdeal
Copy link
Contributor Author

jdeal commented Mar 27, 2022

Hey @lishid, thanks for the suggestions! Sorry for the slow reply, but I made all those changes, which you can see in a comparison here. Let me know if there's anything else I should change.

@lishid
Copy link
Collaborator

lishid commented Apr 5, 2022

@lishid lishid merged commit 61070fb into obsidianmd:master Apr 5, 2022
@jdeal
Copy link
Contributor Author

jdeal commented Apr 5, 2022

Thanks for another catch @lishid! Fixed in a subsequent build, along with another potential null I found. And thanks for merging anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants