Open tiktuk opened 2 years ago
Thanks. Related to #460.
This issue is still affecting me. @schemar are you still aware of this, or did you think that #460 fixed both bugs ?
I'm using obsidian tasks v1.20.0 and when I create a new tasks with CTRL+T
(modal), the cursor is placed at the beginning of the line, which is really annoying when creating multiple tasks in a row.
Having looked at the behaviour of #1424 and at #460, I understand more about #460.
As its summary says, #460 specifically fixed the case when the user ran the Tasks: Toggle task done
command.
That's a different area of code from running the modal.
There would need to be a different fix for this issue.
I would like to see some unifying of the existing code for toggling and editing tasks in different Obsidian Modes (Source, Live Preview and Reading). They differ in subtle ways, and I've tried a couple of times to catalogue the different behaviours and differences in implementation details, but got bogged down each time.
Unfortunately this means that a fix for this is unlikely to come any time soon.
Looking at this issue more closely, it is labelled as an enhancement, but the description is this:
The cursor is placed before the task when creating a new task using the modal
which reads as though it is describing a bug, as it does not say what the actual desired behaviour is.
I was confused by this.
What if the summary were phrased as:
When edits are saved by the modal, always leave the cursor at end of line (in Live Preview and Source modes)
In other words, don't worry about complicated things like trying to preserve the original cursor location when the modal was opened - just always leave the cursor at the end of the line, if the user accepted edits the modal.
@tiktuk @Wenzel are you happy with this simple proposed behaviour? I think it sounds like what you are both requesting.
hi @claremacrae
In other words, don't worry about complicated things like trying to preserve the original cursor location when the modal was opened - just always leave the cursor at the end of the line, if the user accepted edits the modal.
Yes that's what I meant, just put the cursor at the end of the line, so I can press ENTER
and create another task right after.
Thanks ! :christmas_tree:
I would appreciate help on this, and will add the 'help wanted' label.
Tasks: Create or edit task
command
5.Type any old junk in the DescriptionApply
Actual behaviour:
The new task like is written out, like - [ ] asdfafasd
The cursor is placed at the start of the line
Requested behaviour:
The new task like is written out, like - [ ] asdfafasd
The cursor is placed at the end of the line
Here is some background info for anyone who might be interested in looking at the code.
Create or edit task
command is in src/Commands/CreateOrEdit.ts
onSubmit()
- which is what will write the new or edited task back to the note at the line where the cursor was when the command was invoked.new TaskModal(...)
- see src/TaskModal.ts - and the onSubmit
function is passed inIt seems to me that the crucial bit of code for this issue is then the following. Can it be updated to place the cursor at the end of the last line in serialized
- which is likely to have only 1 line - but I am not sure that will always be the case.
I am not sure whether it's relevant, but there is another instance of the TaskModal
and this is how it updates the task:
Please test that the cursor is placed at the end of the line both in Source Mode and Live Preview.
Thank you in advance for any help offered.
Hi,
Thanks for working on this :) .
I would like to test it, but I don't know where to find the new code. Do you have a branch for this work?
What do you mean by the new code @tiktuk
Sorry, I thought you were asking for testing of a possible implementation of the behaviour with the newline at the end of the task.
(I just tested, and the behaviour is the same in source mode, btw.)
Ah no.
I would appreciate help on this, and will add the 'help wanted' label.
When I add the ‘help wanted’ label, to let other programmers know it is a particular issue I would like help on, I try to make an effort to write up enough detail about the code and the issue to get them started easily.
Got it, thanks :) .
That issue still gives me a little pain. That happens only for newly created tasks from shortcut. "Create or edit Task"
If you create checkbox first, and edit it in window, there is no problem.
Expected Behavior
I expected the cursor to be at the end of the line to be able to continue writing out the task. I do this mainly to be able to add tags with autocomplete but also just being able to hit return and go to next line is nice.
Current Behavior
The cursor is inserted in front of the new task.
Steps to Reproduce
Create a new task using the modal.
Context (Environment)