The thought to do what is sinful is also sinful. For example, envy not followed by theft, is still the sin of envy. For lust in general, sixth commandment covers acts and ninth commandment covers thoughts.
Catholic Encyclopedia
Three kinds of internal sin are usually distinguished:
- delectatio morosa, i.e. the pleasure taken in a sinful thought or imagination even without desiring it;
- gaudium, i.e. dwelling with complacency on sins already committed; and
- desiderium, i.e. the desire for what is sinful.
An efficacious desire, i.e. one that includes the deliberate intention to realize or gratify the desire, has the same malice, mortal or venial, as the action which it has in view. An inefficacious desire is one that carries a condition, in such a way that the will is prepared to perform the action in case the condition were verified. When the condition is such as to eliminate all sinfulness from the action, the desire involves no sin: e.g. I would gladly eat meat on Friday, if I had a dispensation; and in general this is the case whenever the action is forbidden by positive law only.
…
The pleasure taken in a sinful thought (delectatio, gaudium) is, generally speaking, a sin of the same kind and gravity as the action which is thought of. Much, however, depends on the motive for which one thinks of sinful actions. The pleasure, e.g. which one may experience in studying the nature of murder or any other crime, in getting clear ideas on the subject, tracing its causes, determining the guilt etc., is not a sin; on the contrary, it is often both necessary and useful. The case is different of course where the pleasure means gratification in the sinful object or action itself. And it is evidently a sin when one boasts of his evil deeds, the more so because of the scandal that is given.
O’Neil, A.C. (1912). Sin. In The Catholic Encyclopedia. New York: Robert Appleton Company.
newadvent.org/cathen/14004b.htm