Texstudio: Default TODO regex doesn't match the manual

Created on 15 Aug 2018  路  5Comments  路  Source: texstudio-org/texstudio


Environment

  • TeXstudio: 2.12.10
  • Qt: 5.11.1
  • OS: Arch linux with kernel 4.17.13-arch1-1-ARCH
  • TeX distribution: texlive (package texlive-full)

Expected behavior

The TexStudio help manual states:
https://github.com/texstudio-org/texstudio/blob/0d2cd12184ab0fdecb2916d78384b79ddaefeb40/utilities/manual/usermanual_en.html#L384-L385

The structure view shows labels, sections, includes and beamer blocks and todos.

There are two kind of todos that will be listed a) todos from a todo-like command, e.g. todo{} from the package todonotes. b) todo-like comments: This is a comment with a capitalized first word, e.g. "% TODO", "%FIXME", "%ASK".

I expect the actual behaviour to be consistent with this one

Actual behavior

Only comments starting with TODO are considered as TODOs, with syntax highlighting, and an entry in the structure view.

I would like the behaviour to be fixed to match the one described in the manual. Alternatively, the manual could be fixed (if only to mention that it is configurable), but I would prefer to retain the original behaviour. If the later is chosen, the TODO keyword might become redundant in the structure view, and could be removed there.

How to reproduce

Write a comment starting with TODO, observe it being highlighted correctly. Write another starting one with ASK; it is being treated as a regular comment.

Notes

I think this behaviour is relatively recent (<2 years). I could have a go at it myself, but you would have to decide on the intended behaviour first.

After a cursory look at the code, it seems to be just a matter of adjusting the default regex here, adjusting the manual, or both.

The regex could be something like %\s*([A-Z]+(\s|$)|todo). I would have liked to make it unicode-aware with something like %\s*(\p{Upper}+(\s|$)|todo) or %\s*(\p{Lu}+(\s|$)|todo), but it doesn't seem to be compatible with the regex engine being used.

All 5 comments

you can set the regexp yourself in the options (options/advanced editor/Regular Expression fro TODO comment). The regular expression needs to comply with QRegExp,see Qt documentation.
I will adapt the documentation on this but not the default as it caused complains.

manual fixed

2.10.0 introduced a hard-coded regular expression similar to %\s*([A-Z]+(\s|$)|todo).

That got a number of complains about too eager highlighting. Therefore we reverted to %TODO only by default and made that expression configurable in Options ->Advanced Editor -> Regular expression for TODO comment. The present default is the intended one. We simply forgot to update the manual.

@sunderme, thanks for fixing this. The wording is still (just) a bit misleading, though (this is a help document, so I think it needs to be precise).

I would suggest "for any capital letter only comment." -> "for any comment starting with capital letters". Not sure how to exactly convey the regexp into relatively simple english, though.

https://github.com/texstudio-org/texstudio/blob/3d716f1bd68eccb64df21371d10e88dacd623d4d/utilities/manual/usermanual_en.html#L385

Was this page helpful?
0 / 5 - 0 ratings