push subtasks in with cmd+shift+(up/down)
Hunter
Friday, June 27th, 2025 at 12:08 AM
871 } else if (e.key === 'ArrowDown' && !e.shiftKey) {
872 e.preventDefault();
873 navigateTasks('down');
874 + } else if (e.key === 'ArrowUp' && e.shiftKey && (e.metaKey || e.ctrlKey)) {
875 + e.preventDefault();
876 + pushSubtaskIntoTarget(task, 'up');
877 + } else if (e.key === 'ArrowDown' && e.shiftKey && (e.metaKey || e.ctrlKey)) {
878 + e.preventDefault();
879 + pushSubtaskIntoTarget(task, 'down');
880 } else if (e.key === 'ArrowUp' && e.shiftKey) {
881 e.preventDefault();
882 moveSubtask(task, 'up');
921 scheduleSave();
922 }
923
924 + function pushSubtaskIntoTarget(subtask, direction) {
925 + // Don't allow pushing the current parent task
926 + if (subtask === currentTask) {
927 + return;
928 + }
929 +
930 + const parentTask = findParentTask(subtask);
931 + if (!parentTask) return;
932 +
933 + const index = parentTask.subtasks.findIndex(t => t.id === subtask.id);
934 + if (index === -1) return;
935 +
936 + let targetTask = null;
937 + if (direction === 'up' && index > 0) {
938 + targetTask = parentTask.subtasks[index - 1];
939 + } else if (direction === 'down' && index < parentTask.subtasks.length - 1) {
940 + targetTask = parentTask.subtasks[index + 1];
941 + }
942 +
943 + if (!targetTask) return;
944 +
945 + // Remove the subtask from its current parent
946 + parentTask.subtasks.splice(index, 1);
947 +
948 + // Add the subtask to the target task's subtasks
949 + targetTask.subtasks.push(subtask);
950 +
951 + // Update parent task state after removal
952 + updateTaskAndAncestors(parentTask);
953 +
954 + // Update target task state after addition
955 + updateTaskAndAncestors(targetTask);
956 +
957 + // Re-render the view
958 + renderCurrentView();
959 +
960 + // Focus on the target task that now contains the moved subtask
961 + selectAndFocusTask(targetTask);
962 +
963 + scheduleSave();
964 + }
965 +
966 function addNewSubtask(parentTask, currentSubtask = null) {
967 const newSubtask = { id: Date.now(), text: '', state: 0, subtasks: [], selectedSubtaskId: null };
968 if (currentSubtask) {