obsidian-tasks-group / obsidian-tasks

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

Task Modal tasks over writes yaml front matter when cursor is in the frontmatter #1361

Open Gr-Nobel opened 1 year ago

Gr-Nobel commented 1 year ago

Please check that this issue hasn't been reported before.

Expected Behavior

Task plugin should always add task after frontmatter.

May be in the future : ability to add task after any heading just like Quick Add plugin

Current behaviour

When I add a task trough the task moder it dismisses the yaml frontmatter.

Steps to reproduce

Just add a task triggering Obsidian directly through task modal. image

Which Operating Systems are you using?

Obsidian Version

latest

Tasks Plugin Version

latest

Checks

Possible solution

No response

claremacrae commented 1 year ago

Hi @Gr-Nobel - that sounds serious, and I would like to investigate it.

I have not seen any previous reports of it, which suggests to me the it may possibly be something specific to your vault.

So please could you disable all other plugins, restart Obsidian and then add here a detailed set of steps on how to reproduce the problem.

Make sure you tell me every single character to type, and record things like which Obsidian mode you are in (source, Live preview...)

Thanks in advance for this info.

claremacrae commented 1 year ago

I have been able to reproduce it if my cursor is in the frontmatter when I open Task modal.

Is that your situation?

The Task modal basically puts the new line where the cursor is.

The workaround would be to put the cursor on the line where you want the new task to go.

Gr-Nobel commented 1 year ago

Hey There ! thanks for replying I'm trying to use auto hot key app to quickly add task to obsidian.

if you have the advanced uri plugin you can paste this :- obsidian://advanced-uri?vault=Nobel Notes&commandname=Tasks: Create or edit task image

into your file explorer it will open the task modal you add the task and it breaks the frontmatter.

I do the same thing with qickadd plugin it adds the task after frontmatter.But quick add doesn't have this feature.

image

Gr-Nobel commented 1 year ago

image completely broke the frontmatter of that page.

claremacrae commented 1 year ago

Oh wow, that is absolutely brilliant. I had no idea that this was possible. Thank you for telling me about that capability!

So, the command specifies a vault to open, but it says nothing about which file should be open.

What if you have no notes open, what happens then?

I think before fixing the code, I would need to understand more about the range of scenarios (no note open, note open but in Reading mode, so note cannot be edited, and so on)

Oh, I'm also confused because the original message referenced QuickAdd, and the above references Advanced URI.

So I still don't have a list of unambiguous steps to follow, to reproduce the problem.

claremacrae commented 1 year ago

Here is the kind of information and level of detail I am after, in terms of steps to enable me to reproduce the problem and be confident that any fix does solve it, please:

https://github.com/obsidian-tasks-group/obsidian-tasks/issues/1300#issuecomment-1306829403

claremacrae commented 1 year ago

image completely broke the frontmatter of that page.

I understand that it is broken, but unfortunately a screenshot does not tell me what happened to break it.

If writing a list of steps is hard, you could always record a video of what you did (if there is no private information that would be shown).

Gr-Nobel commented 1 year ago

thanks again for your reply. I shall make a video and send it to you soon.

A quick question can task plugin add task after a certain heading or to the end of a file just like QuickAdd. image

claremacrae commented 1 year ago

Thanks!

A quick question can task plugin add task after a certain heading or to the end of a file just like QuickAdd.

No, unfortunately it can only add a task where the cursor is, and if it is Source or Live Preview mode.

Also, the docs explain how the cursor position is used: https://obsidian-tasks-group.github.io/obsidian-tasks/getting-started/create-or-edit-task/

So I think in your situation you would also need to make sure the cursor is on a blank line.

claremacrae commented 1 year ago

If there is no cursor position, then currently it puts the new task on line 1, which is the behaviour you are seeing.

Gr-Nobel commented 1 year ago

What if you have no notes open, what happens then?

By this question I understood the problem fully. If you close all your notes before closing obsidian the task modal doesn't appear. but when a note is open and I close amd open obsidian with the uri. the cursor is always at the first line. may be because of the obsidian behaves that way. the task plugin adds the task there.

it would be great to be able to select the option at the task modal to append the task at the end of the file and also the file name like the due dates can be selected through the task modal.

then I can fully implement Ctrl+Space and boom you add a task to your inbox or the daily note. Which I currently do with todoist.

claremacrae commented 1 year ago

it would be great to be able to select the option at the task modal to append the task at the end of the file and also the file name like the due dates can be selected through the task modal.

I will have a think about what to do, but I have to say that this is not something that is going to implemented soon.

I think the following would be a more robust thing for you to try:

There are also going to be other existing plugins that each provide commands to do a piece of what you want:

The Commander Plugin then has a Macro builder, to allow you to create a new command that executes the list of steps above.

So I think the most realistic thing to do for now is to build a set of steps that gives you the behaviour you want.

So once it is all set up, your keyboard set up would do something like the following:

claremacrae commented 1 year ago

open a specific file

See: Hotkeys for specific files https://publish.obsidian.md/hub/02+-+Community+Expansions/02.05+All+Community+Expansions/Plugins/obsidian-hotkeys-for-specific-files

claremacrae commented 1 year ago

position the cursor in a particular place

See: Scroll to Top Plugin https://publish.obsidian.md/hub/02+-+Community+Expansions/02.05+All+Community+Expansions/Plugins/obsidian-scroll-to-top-plugin

It also has an option to scroll to the end of the file.

Gr-Nobel commented 1 year ago

I fixed it with advanced URI Run "obsidian://advanced-uri?daily=true&commandname=Tasks: Create or edit task&mode=append" it appends the task to my daily note.