## #739 \todo missing in the Structure View

None
open
nobody
1
2014-07-02
2014-07-01
Mathieu2L
No

Hi,
That's midway between a bug and a feature request. Since TXS 2.8, my `\todo*{Thing to do}` are highlighted in green (which is nice). However, they are not added to the list of todo inside the Structure View (which seems to be a bug, according to the "What's new" of version 2.8.0).
Thanks

## Discussion

• \todo* is not defined, only \todo

• \todo* is not mentioned in the manual either (todonotes)

• Mathieu2L
2014-07-01

Well, the manual says "todo-style commands (e.g. \todo{}) are added to the list of todos". Sure I agree it doesn't mention \todo*, but pretty close :-)

And, on my side, \todo and \todo* behave exactly the same (that why I hinted a bug): the text following those commands is green-highlighted but nothing appears in the Structure View. (Perhaps I'm wrongly understanding the "are added to the list of todos" which means to me that they should appear on the TODO entry of the Structure View.)

Edit. ok, I think the misunderstanding may come from the package(s). I'm refering to the `todo` package.

Last edit: Mathieu2L 2014-07-01
• well, here \todo{text}, text is added to the TODO list ...

• Mathieu2L
2014-07-01

I think the difference comes from the package:
- your \todo{text} behaves as you say provided that \usepackage{todonotes} is written.
- otherwise, it is still highlighted in green but not added to the TODO list (which I found strange).

So I'd transformed this bug into a feature request, requesting that the todo package is handled the same way as the todonotes.

• Also strange:

If no } is there, everything afterwards is green

If a %} is there, it is treated like }

• Tim Hoffmann
2014-07-01

The above effects are the result of a compromize:

• Adding todo content to the structure panel is handled by the internal parser: LatexDocument::patchStructure() (latexdocument.cpp l.516). The known commands are specified via cwl.
Advantages: The argument can be extracted (necessary requirement). Known commands can are defined dynamically via the cwl mechanism.
Disadvantages: No standard mechanism for highlighting the argument. Doesn't work for mutli-line comments.

• The Highlighting specified in the language definition (tex.qnfa).
Disadvantages: The definition is static (everything command starting with `\todo` is interpreted as the start of a todo note). The definition is not exact (highlighting extends up to the next non-escaped curly brace).

Given the current limitations, this was the best I could implement with reasonable effort. It works well for most standard situations. I think, living with these limitations is better than having no highlighting and structure-panel addition for \todo commands at all.

A better support would probably require a complete rewrite of the internal LaTeX parser and an extension for dynamic modification of the highlighter rules.

• Tim Hoffmann
2014-07-01

Workaround for `\todo*`: Add this command to a cwl file and define it as todo-like

```\todo*{note}#D
```

• Tim Hoffmann
2014-07-01

Ticket moved from /p/texstudio/bugs/1029/

• Mathieu2L
2014-07-02

The workaround works fine with me. Thanks!