obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.14k stars 216 forks source link

Make separator between dataview components configurable #2783

Closed jonas-schulze closed 1 week ago

jonas-schulze commented 2 weeks ago

⚠️ Please check that this feature request hasn't been suggested before.

🔖 Feature description

You should add a configuration option to automatically add , instead of in front of dataview components.

✔️ Solution

The added configuration option should affect the following part of the code.

https://github.com/obsidian-tasks-group/obsidian-tasks/blob/48e82505bc72511d595186d86bdc78c9a812a274/src/TaskSerializer/DataviewTaskSerializer.ts#L129-L134

The default/current behavior could, e.g., be named "Separate by two spaces". If set to "Separate by comma", above lines should behave like:

return shouldMakeInlineField
    ? `, [${stringComponent.trim()}]`
    : stringComponent;

❓ Alternatives

You could separate by , regardless. Though, I did not consider all the situations where adding a leading comma may be undesirable. Given that #1505 is still open (as of 2024-04-26), I suppose that all dataview fields are at the end of a line. If that is the case, I personally would not mind the initial comma.

📝 Additional Context

Such a configuration option would allow the tasks plugin to play more nicely with the "Remove multiple spaces" option of the linter. In particular, when marking a task done from within a tasks view, the linter is not run over that file to remove the leading spaces of the added [completion:: today]. When the user is later editing that file directly, the linter is removing the duplicate space. This introduces unnecessary changes when synchronizing the vault using Git.

Furthermore, suppose a user manually added , in between two dataview components. After editing that task using the "Tasks: Create or edit task" command/GUI, all the , will be replaced by . For example,

- [ ] foo, [priority:: high], [due:: 2024-04-26]

becomes

- [ ] foo,  [priority:: high]  [due:: 2024-04-26]

when immediately confirming the GUI dialog. Note the two spaces after the comma. Upon saving, the linter replaces the task by

- [ ] foo, [priority:: high] [due:: 2024-04-26]
claremacrae commented 2 weeks ago

Thanks for the suggestion.

I am concerned about the complications that this would introduce for users who already have space-separated dataview fields in their tasks, and then change the setting.

Please have a read of What do I need to know about the order of items in a task?. A comma between fields would break parsing, currently, as it is not a space.

I can't see a clean (maintainable) way of implementing this suggestion in the current code.

Once https://github.com/obsidian-tasks-group/obsidian-tasks/issues/1505 is implemented, this request would be easier to implement.

But I do feel that the right solution is for somebody to take the time to report the underlying Issue on the Obsidian Forum - that Obsidian displays reference-style links incorrectly in Live Preview mode.

claremacrae commented 1 week ago

But I do feel that the right solution is for somebody to take the time to report the underlying Issue on the Obsidian Forum - that Obsidian displays reference-style links incorrectly in Live Preview mode.

I've reflected on this, since writing the above. I am sure that it is the correct solution to the problem. @jonas-schulze, if you want to pair together to work on a Forum bug report, please email me at the address in my GitHub profile.

In view of this size of the backlog for this project, and the demotivating effect of a very long backlog on volunteer energy levels, I'm going through a continual process of reviewing tasks for things that are one or more of the following:

So I'm marking this one as 'not planned'. This doesn't mean 'won't fix' - it means not likely to be done in the foreseeable future.