Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot match all projects or contexts using + or @ #616

Closed
jloow opened this issue Dec 13, 2023 · 13 comments
Closed

Cannot match all projects or contexts using + or @ #616

jloow opened this issue Dec 13, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@jloow
Copy link

jloow commented Dec 13, 2023

Bug Report

App Version: 2.0.3

Platform: macOS

Installation Method: Direct Download

Bug Description:
Using advanced search, I cannot filter my todo for + or @ (which is supposed to match any todo with a project or context). It is possible to match other projects or context using +test or @test. Specifically I would like to filter for any todos without a project (i.e. "!+" or "not +") or without a context (i.e. "!@" or "not @")

Steps to Reproduce:

  1. Enter, e.g., "+", "!+", "not +", "@", "!@" or "not @" without quotations marks in the search field.

Expected Behavior:
To find todos that don't have any project or that don't have any context.

Actual Behavior:
When using NOT operators, no todos are displayed. Otherwise, all todos are displayed.

Additional Information:
The same bug is present in 2.0.2 installed through homebrew.

@jloow jloow added the bug Something isn't working label Dec 13, 2023
@jloow
Copy link
Author

jloow commented Dec 13, 2023

I also tested this on Linux, and it seems to be an issue there as well.

@ransome1
Copy link
Owner

@jloow can you please share an example todo list, the exact search string you're applying and the expected result?

@jloow
Copy link
Author

jloow commented Dec 13, 2023

Sure!

Example todo.txt:

2023-12-13 Test 1 +project_a
2023-12-13 Test 2 +project_b
2023-12-14 Test 3 @context_a
2023-12-14 Test 4 @context_b
2023-12-15 Test 5 +project_a @context_a
2023-12-15 Test 6

Search string: +

Expectation:

2023-12-13 Test 1 +project_a
2023-12-13 Test 2 +project_b
2023-12-15 Test 5 +project_a @context_a

Result:

2023-12-13 Test 1 +project_a
2023-12-13 Test 2 +project_b
2023-12-14 Test 3 @context_a
2023-12-14 Test 4 @context_b
2023-12-15 Test 5 +project_a @context_a
2023-12-15 Test 6

Search string: @

Expectation:

2023-12-14 Test 3 @context_a
2023-12-14 Test 4 @context_b
2023-12-15 Test 5 +project_a @context_a

Result:

2023-12-13 Test 1 +project_a
2023-12-13 Test 2 +project_b
2023-12-14 Test 3 @context_a
2023-12-14 Test 4 @context_b
2023-12-15 Test 5 +project_a @context_a
2023-12-15 Test 6

Search string: !+ or not +

Expectation:

2023-12-14 Test 3 @context_a
2023-12-14 Test 4 @context_b
2023-12-15 Test 6

Results: None.


Search string: !@ or not @

Expectation:

2023-12-13 Test 1 +project_a
2023-12-13 Test 2 +project_b
2023-12-15 Test 6

Result: None.

@ransome1 ransome1 moved this to Backlog in sleek 2.x Dec 14, 2023
@ransome1 ransome1 moved this from Backlog to Bugs in sleek 2.x Dec 18, 2023
@ransome1
Copy link
Owner

@jloow this does not solve the issue at hand – which I have to admin, I have not looked into yet – but since you are using the advanced search, you might be interested in a proof of concept, that has been implemented based off this feature request: #179

Feel free to test it out and share your feedback.

@ransome1
Copy link
Owner

@zerodat are you around these days? @jloow report is valid. The Wiki says @ or + should narrow down the list to contexts or projects.

But doing so has no effect.

I also looked into the implementation but could not figure out exactly how it works. The easiest would probably be, if you could take a look at it.

At some point, we should add some test cases, since this is easy to test.

@zerodat
Copy link
Collaborator

zerodat commented Jan 17, 2024

@ransome1, I'm still out here. 😄 I'll try to take a look at this issue.

@zerodat
Copy link
Collaborator

zerodat commented Jan 17, 2024

@ransome1 still taking a preliminary look and I will be busy for the next 8 or 10 hours, but later I will look deeper. The code for the query engine seems basically the same as it was back in the 1.2.9 version. I confirmed that it works properly in that version. What should be happening is that in the case of a query like "@" or "+" it will check the state of todoObject.contexts (line 127 of FilterQuery.js) or todoObject.projects (line 113). That all looks like it ought to work unless the todoObject is much different now in version 2 of sleek. I'll try to do some debugging later to see where it is going wrong.

zerodat added a commit to zerodat/sleek that referenced this issue Jan 17, 2024
@zerodat
Copy link
Collaborator

zerodat commented Jan 17, 2024

@ransome1, I confirmed that this worked in 1.2.9 and no longer works in 2.0.6.

The problem seems to be that I tested for the list of projects or contexts to be empty by just testing todoObject.contexts (or projects) as a boolean value. That works if the contexts is null or undefined when there are none. However, in Javascript an empty list tests as "true" (which is the opposite of the behavior in Python, my usual language).

It seems like the 2.0.6 version is setting contexts or projects to an empty list rather than undefined in the case where there are no contexts or projects. Maybe that's a change in behavior of the upstream todo parser.

In any case, we need to change the code in FilterQuery.js to test the length of the list explicitly. I'm submitting a pull request that fixes the issue.

zerodat added a commit that referenced this issue Jan 17, 2024
projects/contexts list length, addresses #616
@ransome1
Copy link
Owner

@jloow I can confirm that @zerodat PR fixed this. I will include it into the next release.

@ransome1 ransome1 moved this from Bugs to In Progress in sleek 2.x Jan 19, 2024
@jloow
Copy link
Author

jloow commented Jan 20, 2024

Great! I've been a bit busy but I'll be sure to check out the next release.

@ransome1
Copy link
Owner

@jloow
Copy link
Author

jloow commented Jan 22, 2024

I've done some quick testing and this seems to have been fixed. The other updates work really well as well.

How does this work - do I close the issue?

@ransome1
Copy link
Owner

How does this work - do I close the issue?

Yes please :)

@jloow jloow closed this as completed Jan 22, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in sleek 2.x Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants