SebastianMC / obsidian-custom-sort

Take full control over the order and sorting of folders and notes in File Explorer in Obsidian
GNU General Public License v3.0
255 stars 19 forks source link

`target-folder` Setting Not Working on Desktop #56

Closed be-studio closed 1 year ago

be-studio commented 1 year ago

Hi @SebastianMC ,

Well done on an excellent and very useful plugin!

I have a sortspec.md file in a folder: Data/Sorting as follows:

sorting-spec: |
  target-folder: Development/C
  Boilerplate
  Comments
  Output
  Input
  Number Literals
  Variables
  Primitives

  target-folder: Notes/Git
  Theory
  Commands

The sorting occurs nicely and with no problems on my mobile (iPhone), but not on desktop (Mac) after toggling the ribbon icon. There is no error reported. I have tried to play around with the target-folder setting to not avail. The only solution appears to be to place a sortspec.md file within the Development/C folder without the target-folder setting, but I don't want to have a separate sortspec.md per folder and prefer to keep all settings in one file as I have tried to do.

The version of the plugin I am using is 1.6.2 installed through Obsidian, Obsidian version 1.1.9, on Mac OS Ventura version 13.2 running on a MacBook Pro Apple Silicon M1 laptop.

Is there a solution to this please? Or is this a potential bug?

Thank you for your attention.

SebastianMC commented 1 year ago

Hi @be-studio

thanks for the report and for including the details necessary to reproduce the specific scenario

The described behavior looks like a potential bug

thanks!

SebastianMC commented 1 year ago

Hi @be-studio

initial tests on my side showed the feature working correctly on macOS Monterey 12.6.x (Intel and M1 macs) Unfortunately I don't have here a mac with macOS Ventura to test Knowing (from your detailed report) that the custom sorting works on iPhone, and at the same time (the same vault, the same configuration), it doesn't work on the mac Ventura, suggest the issue could be related to the macOS system version.

As you narrowed down the issue, the problem seems to be around matching the Development/C against the folder name on macOS Ventura specifically.

In the very first step of troubleshooting, let's do a quick test on your machine taking advantage of one of advanced features of the plugin.

Please update the sortspec.md file in the folder Data/Sorting and replace the line:

  target-folder: Development/C

with the three below lines:

  target-folder: regexp: debug: Development/C
  target-folder: regexp: debug: /C$
  target-folder: regexp: debug: for-name: C

then show the developer console in Obsidian and toggle the ribbon button to (re)enable custom sort. Finally observe the debug output generated by the regular expressions, whenever a folder matches one of them. This should help in determining how the vault folder Development/C appears internally to Obsidian and to the plugin

I'm attaching below a screenshot of how the debug output looks in the test vault on my side

bug-56-investigation

Then please let me know what debug output do you see on Ventura

We should be able to determine the Ventura-specific problem and, as a side-effect, we could be able to form a regexp-based target-folder: specification for you to use (until it is addressed in the plugin)

thanks in advanvce, looking for your feedback

Seb

SebastianMC commented 1 year ago

Hi @be-studio

I did a test on macOS 13.2 Ventura on Intel-based MacBook Air and the specific scenario works fine.

Knowing that, capturing the debug output on your machine becomes crucial in order to troubleshoot the problem.

What is most confusing for me is the fact, that sorting of the same (shared) vault works on an iphone correctly, while fails on macOS.

be-studio commented 1 year ago

Hi @SebastianMC ,

Sorry not to have got back to you sooner. I really appreciate the prompt and very active investigation you are performing on this issue. I will see what debug output I can retrieve and send this across shortly. Thanks again for the excellent support.

be-studio commented 1 year ago

Hi @SebastianMC ,

Thank you for your patience. I have run the plugin on my version of Obsidian.

The first screenshot shows the dev console with the problem I am facing...the sortspec.md is on the screen located in Data/Sorting.

Untitled

The second screenshot shows the three lines of debug code you asked me to add to sortspec.md and this resolves the issue as you can see from the sidebar. Using just the one line: target-folder: regexp: Development/C resolves the issue, i.e., using the regexp: syntax as opposed to using target-folder: Development/C.

Screenshot 2023-02-15 at 14 24 45

So, there is a workaround using regexp, but I imagine maybe there is a bug where target-folder is used without regexp?

I hope this all helps. Thanks again.

SebastianMC commented 1 year ago

Hi @be-studio

thank you for the next round of detailed input! It definitely helps!

Based on the details I started a more focused investigation. In result I identified and fixed a bug #58 - Some target-folder: get ignored when sorting specs are read from two or more notes

Please update the Custom Sorting plugin to the recent release 1.6.3 and see if it resolved the incorrect behavior which your observe.

At the same time, my gut feeling is that while the fixed bug #58 is related to the issue on your side, it will not resolve your specific scenario. Basically the bug affected only the cases with multiple sorting specs residing in multiple notes. Please see if after updating the plugin the problem persists. Then I will continue. Knowing that the regexp-based workaround works, I can guide you to finetune the regexp(s) configuration with one hand, and with the second hand keep identifying the other potential bug responsible for the exact scenario on your side.

be-studio commented 1 year ago

Hi @SebastianMC ,

Thank you again for taking time to investigate and attempt to fix this problem. Unfortunately, after updating my Mac version of the plugin to 1.6.3 I am still witnessing the same problem when I remove regexp: from the target-folder line in sortspec.md. Restoring regexp: rectifies the issue.

Adding debug: with regexp: shows me a regexp match with the target folder in the developer console, but no such or other messages without regexp:.

Incidentally, there is no problem on my iPhone with the new version of the plugin.

Please let me know if there is any other information you need. Thanks again.

SebastianMC commented 1 year ago

Oki doki, let's dive into doing a series of focused tests :-) Knowing that iPhone Obsidian has no problems with sorting is a crucial input here. I'd like you to do a series of simple tests (on mac) and send me the results.

Your original sorting specification starts with the following:

---
sorting-spec: |
  target-folder: Development/C
  Boilerplate
  // and it continues .......
---

and we know it doesn't work.

Please replace the line target-folder: Development/C with:

  1. target-folder: regexp: debug: for-name: C$

so that your config starts with:

---
sorting-spec: |
  target-folder: regexp: debug: for-name: C$
  Boilerplate
  // and it continues .......
---

Then refresh the sorting and observe console output. And collect the screenshot or the relevant text of the console output line.

Then repeat the same procedure with each of below replacements and collect the output (screenshot or the relevant text line of console, whatever is more convenient for you):

  1. target-folder: regexp: debug: for-name: ^C
  2. target-folder: regexp: debug: for-name: ^C$
  3. target-folder: regexp: debug: for-name: Development
  4. target-folder: regexp: debug: for-name: Development$
  5. target-folder: regexp: debug: for-name: ^Development
  6. target-folder: regexp: debug: for-name: ^Development$
  7. target-folder: regexp: debug: /C$
  8. target-folder: regexp: debug: Development/C
  9. target-folder: regexp: debug: evelopment/C
  10. target-folder: regexp: debug: ^Development/C
  11. target-folder: regexp: debug: Development/C$
  12. target-folder: regexp: debug: ^Development/C$
  13. target-folder: regexp: debug: ^.+evelopment.+C$

The results of this series of tests have a twofold purpose:

I'm considering many things, like interference with some other plugin, or a specific setup of the filesystem on your mac so that the folder Development is presented under a non-standard name. Other options are possible and the very first step in troubleshooting is to determine, how the Development folder is seen by Obsidian.

Awaiting your input and collected test results

At the same time please be aware that I'll become unavailable from now till the end of February, and I could have no chance to respond in that time window

thanks, Seb

be-studio commented 1 year ago

Hi @SebastianMC ,

Thanks for the continued investigations. I've taken note of you being unavailable. I'm also busy at the moment, but will look into this, hopefully, over next week or so.

be-studio commented 1 year ago

Hi @SebastianMC ,

I'm sorry, but it appears that your plugin isn't the culprit after all, but a quirk in Obsidian, and apologies for taking you through the lengthy investigations. I discovered that it is possible, although undesirable, to open a vault on mobile and to open a different vault on desktop with both referencing the same set of folders and notes. This means that the URL to a particular folder/note or other file differs between mobile and desktop. In my case desktop URLs would point to say Notes/Development/C whereas on desktop the URL has to be Development/C.

I believe this URL difference between mobile and desktop interferes with the sortsepc.md target-folder setting, which regexp 'fixes'.

I have verified this situation to be the case by having done a lengthy re-configuration of my Obsidian setup so that both mobile and desktop access the same vault where the URLs work the same way on both platforms. Your plugin works as intended and without the regexp setting.

Again, apologies for all the resultant trouble. Your plugin is definitely a useful addition to the Obsidian toolkit and your hard work is much appreciated. 👍 Thanks!

SebastianMC commented 1 year ago

Hi @be-studio,

thank you for the final report allowing me to close the ticket! It happens that people abandon conversation leaving it in an unclear 'dangling' state.

No problem at all - as part of the investigation based on your input I captured a major bug (#58). It was in the area of code not covered by unit tests so only a targeted focused manual tests could catch it. A nice coincidence!

There also was a chance that some relevant yet uncovered scenario could be identified and addressed. Eventually - as you describe - the issue was a result of some unusual setup on your side, not qualifying to be treated as a regular use case. And the regexp-based target-folder: can handle the folder paths which differ in prefix anyways.

When you report a ticket you never know ;-)

Thanks!