Closed GitHunter0 closed 1 year ago
This isn't as simple as you might think because the extension doesn't really know anything about where you are in the current file. I'll see what I can come up with though.
Understood, thanks, I appreciate the effort.
Just uploaded a new version with Todo Tree: Go To Next and Todo Tree: Go To Previous which can be bound to whatever keys you want.
Let me know if it works as expected.
@Gruntfuggly, thanks man, this is really helpful.
The only thing I expected to be different is that the cursor is not being positioned right in the beginning of the tag line but in the last line before the next tag.
Here's an example, I configured #%%
as a tag and I expected the cursor to go from section 1
to section 2
. Instead, it's going from section 1
to last line
:
Can you post your config so I can try it out?
Sure, this my user settings.json part:
"todo-tree.tree.buttons.export": true,
"todo-tree.tree.scanMode": "current file",
"todo-tree.tree.showBadges": false,
"todo-tree.tree.buttons.scanMode": true,
"todo-tree.tree.showScanModeButton": true,
"todo-tree.general.tags": [
"#%%",
"#%%%",
"#%%%%",
"#%%%%%"
],
Actaully - can you post a section of the code too (sorry - should have asked yesterday!) What sort of file is it?
No problem @Gruntfuggly , it's just a python file (a text file with .py
extension), for example test.py
:
#%% section 1
#%%% subsection 1
#%%% subsection 2
#%% section 2
# line 1
# line 2
import numpy as np
import pandas as pd
# last line
#%% section 3
Sorry - I think I'll need your regex setting too.
No problem @Gruntfuggly, but I don't know what regex setting you are referring to, where can I find that?
I can't get it to do what you're seeing, but I have noticed one thing -yYour configuration is not really using much of the regex - it matches the start of line character. I can make it work properly by just removing the |^
from the regex and then changing your tags: e.g.
"todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^[ \\t]*(-|\\d+.))\\s*($TAGS)",
"todo-tree.general.tags": [
"%%",
"%%%",
"%%%%",
"%%%%%"
],
Now it matches the #
as the comment character and the the tag is the bit that follows.
I'll see if I can make it work more sensibly with your original configuration though.
I'll see if I can make it work more sensibly with your original configuration though.
I appreciate that, because %%
is an operator in Python and should not be interpreted as a tag, so I will really need the #
in the tags.
Do you use any other tags? If not, you could simplify the regex down to
"todo-tree.regex.regex": "#($TAGS)",
which would only match your tags if they were preceded by the hash.
Thank you @Gruntfuggly, your workaround is working fine! I don't use other tags at the moment.
OK - I think I have a fix for your original configuration too! 8-)
Hey @Gruntfuggly ,
It would be really useful to be able to navigate to the previous or next tag using keyboard shortcuts like Comment Anchors does.
It is the only essential feature I miss in
todo-tree
, which is overall a great extension.Thank you