Skip to content

Conversation

claremacrae
Copy link
Collaborator

@claremacrae claremacrae commented Sep 30, 2025

This is an experiment to aid discussion on:

It's purely so that a build is created, for users to experiment with this implementation and give feedback.

There is no intention to merge this branch to main.

Feedback

Please put any feedback in:

How to test this

  1. Go to https://github.com/obsidian-tasks-group/obsidian-tasks/actions/runs/18124750481
  2. Download and expand the file dist-verified file
  3. You will now have a new Tasks distribution which you can add in to your main vault, or a test vault

The Changes

This adds:

  • task.file.propertyAsLink('property-name') - which returns the property as a Link or a null
  • Link.asFile() which returns a TasksFile representing the link destination, or null

For context, TasksFile is the type of task.file.

An example of use, based on 4 test files that I added in PR...

```tasks
filename includes chain_link

# TODO Make 'group by' detect if the object is a link, and group by its markdown

group by function 'Level 1 link: ' + \
    task.file.\
        propertyAsLink('link_to_file').markdown

group by function 'Level 2 link: ' + \
    task.file.\
        propertyAsLink('link_to_file').asFile().\
        propertyAsLink('link_to_file').markdown

group by function 'Level 3 link: ' + \
    task.file.\
        propertyAsLink('link_to_file').asFile().\
        propertyAsLink('link_to_file').asFile().\
        propertyAsLink('link_to_file').markdown

group by function 'Level 4 link: ' + \
    task.file.\
        propertyAsLink('link_to_file').asFile().\
        propertyAsLink('link_to_file').asFile().\
        propertyAsLink('link_to_file').asFile().\
        propertyAsLink('link_to_file').markdown

```

# Conflicts:
#	tests/Scripting/TasksFile.test.ts
… loaded yet

This will make tests of Links easier to write, as we won't have to force
the tests to manually pre-load files being linked to.
@claremacrae claremacrae added the type: internal Only regards development or contributing label Sep 30, 2025
@claremacrae claremacrae marked this pull request as draft September 30, 2025 09:12
claremacrae and others added 22 commits October 3, 2025 10:11
Co-Authored-By: Ilyas Landikov <93825870+ilandikov@users.noreply.github.com>
LinkResolver is now set up globally, so tests don't need to be resetting its
global state.
LinkResolver is now set up globally, so tests don't need to be resetting its
global state.
The file name has two spaces in, and the link was missing a closing ]
Copy link

sonarqubecloud bot commented Oct 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: internal Only regards development or contributing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant