Skip to content

Sort tasks by Taskfile definition order when using default sort #230

@kyrokode

Description

@kyrokode

Currently, when taskfile.tree.sort is set to "default", tasks in the sidebar are displayed in the order returned by the task CLI, which does not necessarily match the order in which they are defined in the Taskfile.

This can be confusing for users who carefully organize their Taskfile, expecting the sidebar to reflect the same structure.

Proposed behavior:

When the sort mode is "default", tasks and namespaces should be sorted by their location.line property, preserving the original definition order from the Taskfile.

Example:

Given this Taskfile:

tasks:
  build:
    desc: Build the project
  test:
    desc: Run tests
  lint:
    desc: Lint the code

The sidebar should display: build, test, lint — not alphabetically or in an arbitrary order.

For namespaces (included Taskfiles), the namespace position is determined by the smallest location.line of its contained tasks, scoped to the parent Taskfile to prevent included files from pulling a namespace out of order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions