commit 08b926cb754bbe3a852564ba87d98400b1e0d5a3
parent eb657dfabbe7d9bb832910017b14832095f269f8
Author: Hunter
Date:   Fri, 27 Jun 2025 00:08:49 -0400

push subtasks in with cmd+shift+(up/down)

Diffstat:
Mindex.html | 48++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+), 0 deletions(-)

diff --git a/index.html b/index.html @@ -871,6 +871,12 @@ } else if (e.key === 'ArrowDown' && !e.shiftKey) { e.preventDefault(); navigateTasks('down'); + } else if (e.key === 'ArrowUp' && e.shiftKey && (e.metaKey || e.ctrlKey)) { + e.preventDefault(); + pushSubtaskIntoTarget(task, 'up'); + } else if (e.key === 'ArrowDown' && e.shiftKey && (e.metaKey || e.ctrlKey)) { + e.preventDefault(); + pushSubtaskIntoTarget(task, 'down'); } else if (e.key === 'ArrowUp' && e.shiftKey) { e.preventDefault(); moveSubtask(task, 'up'); @@ -915,6 +921,48 @@ scheduleSave(); } + function pushSubtaskIntoTarget(subtask, direction) { + // Don't allow pushing the current parent task + if (subtask === currentTask) { + return; + } + + const parentTask = findParentTask(subtask); + if (!parentTask) return; + + const index = parentTask.subtasks.findIndex(t => t.id === subtask.id); + if (index === -1) return; + + let targetTask = null; + if (direction === 'up' && index > 0) { + targetTask = parentTask.subtasks[index - 1]; + } else if (direction === 'down' && index < parentTask.subtasks.length - 1) { + targetTask = parentTask.subtasks[index + 1]; + } + + if (!targetTask) return; + + // Remove the subtask from its current parent + parentTask.subtasks.splice(index, 1); + + // Add the subtask to the target task's subtasks + targetTask.subtasks.push(subtask); + + // Update parent task state after removal + updateTaskAndAncestors(parentTask); + + // Update target task state after addition + updateTaskAndAncestors(targetTask); + + // Re-render the view + renderCurrentView(); + + // Focus on the target task that now contains the moved subtask + selectAndFocusTask(targetTask); + + scheduleSave(); + } + function addNewSubtask(parentTask, currentSubtask = null) { const newSubtask = { id: Date.now(), text: '', state: 0, subtasks: [], selectedSubtaskId: null }; if (currentSubtask) {