Continuing Issues with Visual Studio Task List for .ps1 Files in Visual Studio Editor with Updated PoshTools

Issue #166 resolved
Nick De Lancie created an issue

For VS Community 2019 v. 16.2.2 | PoshTools v. 4.9.0 (not Pro) | $PSVersionTable output at end

With respect to the just-updated PoshTools to address the prior Visual Studio Task List issues, there remain some issues that should be fixed or noted.

First, as the baseline to evaluate how, after installing Posh Tools v. 9.9.0, the VS Task List now works with .ps1 files, I tried various scenarios in a VS session without any options changes (except adding a couple of new tokens by Tools > Options > Environment > Task List) in a VB.Net project with open .vb files containing various of these tokens.

The baseline is that (i) any line in a .vb that contains a Task List token (case insentitive) that is (A) preceded by, in order, (1) zero or more non-comment character characters (including whitespace characters);  (2) one comment character; and (3) zero or more whitespace characters; and (B) followed by either (1) a newline; or (2) whitespace or a punctuation character (with optional other characters thereafter), will be recognized immediately in the Task List (in regex terms--I think:

^[^']*?'\s*(TODO|HACK|etc.)(\W+.*)*$

) ; and (ii) when a new token is added to the Task List, a line containing that token and conforming to the clause (i) is immediately referred to in the Task List.

Hence, all the following work in a .vb file ('TOKEN' having been added to the list of Task List tokens):

'TODO
'TODO(sometext--any non-word character appears to delimit the token)
'TODO some text
' TODO (space after comment character)
' TODO (tab after comment character)
[code line]'TODO (text before, but no whitespace immediately before, comment character)
[code line] 'TODO (text, including whitespace, before comment character)
    [code line] ' TODO (text, including whitespace, before, and space after, comment character)

'TOKEN
'TOKEN some text
' TOKEN (space after comment character)
' TOKEN (tab after comment character)
[code line]'TOKEN (text before, but no whitespace immediately before, comment character)
[code line] 'TOKEN (text, including whitespace, before comment character)
    [code line] ' TOKEN (text, including whitespace, before, And space after, comment character)

Now, in the same Visual Studio session, but with a PowerShell project and .ps1 files open, or after quitting and restarting VS, the Task List works or--more importantly--does not work the same way for the following variations of the above (# substituted for ' as comment character):

#TODO
#TODO(sometext--any non-word character appears to delimit the token)
#TODO some text
# TODO (space after comment character) <-- does not work
# TODO (tab after comment character) <-- does not work
[code line]#TODO (text before, but no whitespace immediately before, comment character) <-- does not work

[code line] #TODO (text, including whitespace, before comment character)
[code line] # TODO (text, including whitespace, before, and space after, comment character) <-- does not work

#TOKEN
#TOKEN some text
# TOKEN (space after comment character) <-- does not work
# TOKEN (tab after comment character) <-- does not work
[code line]#TOKEN (text before, but no whitespace immediately before, comment character) <-- does not work

[code line] #TOKEN (text, including whitespace, before comment character)
[code line] # TOKEN (text, including whitespace, before, and space after, comment character) <-- does not work

Further, while VB>Net does not have a block comment construct, task list tokens in .ps1 file block comments (<# ... #>) are not recognized at all no matter where placed and no matter by what preceded or followed.

Further still, if one tries to enable e.g., the '# TODO' token pattern (space after comment character and before token), by adding ' TODO' (space before token word) to the Task List, that will be recognized in .ps1 (subject to the final comment below), but then, back in .vb projects, the TODO token will be recognized twice for those having the space between the comment character and the token (the number of TODOs of that pattern will double), apparently being recognized once for the "TODO" and again for the " TODO" as separate patterns, just as if one had TODO and HACK on the same line. Even so, one cannot get the ‘#    TODO' token pattern (tab after comment character and before token) recognized at all (a VS issue, however, I’d guess).

Finally, with .ps1 files/PowerShell projects--unlike with .vb files/VB.Net projects--in order to have a custom token that is added to the list of Task List tokens recognized by Visual Studio, one needs to exit VS and restart it. In a VB.Net project, as noted above, the recognition is immediate on completing the Add and closing the Task List Options dialog.

So, in summary, v. 4.9.0 is a good first step at fixing the Task List token issues in PoshTools I previously identified (by recognizing custom tokens), but some bugs still need to be worked out (whitespace after comment character, non-whitespace character immediately before comment character, and need to quit and restart VS to have a newly added token recognized).

Thanks for work on improving PoshTools!

Best, Nick

\$PSVersionTable:

Name                                    Value
----                                        -----
PSVersion                              5.1.15063.1805
PSEdition                               Desktop
PSCompatibleVersions          {1.0, 2.0, 3.0, 4.0...}
BuildVersion                          10.0.15063.1805
CLRVersion                            4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion  2.3
SerializationVersion                1.1.0.1

Comments (4)

  1. Adam Driscoll

    Thanks for all the feedback! I just made a change to implement the token search as a regex rather than just a StartsWidth (which it was doing before). This should match all the examples you've posted. I need to figure out how to listen for events in VS that happen when the tokens change. Look them up every time is slow because this code runs in the tokenizer, every time you type a character.

  2. Log in to comment