Got me this here flamethrower.
Just gonna fire off a few lengthy bursts over there. And here. Some more there.
Not tryin' ta attack you good folks! Just firin' me flamethrower. Still invisible!
Yup!
Gonna toss me some grenades in a moment as well. All nice and casual like.
Lose a limb or two? A friend. All good!
Still invisible.
Yup!
And this is how
invisibility works re: the 5e RAW. You might like it, you might not, you might even be attached to the way the spell ended in previous editions. But in 5e it ends (by its own description) by the target attacking (game term) or casting a spell (game term.) It does
not end by
any other method any more than
mage armour or
fly would end by using a breath weapon or hurting someone's feelings!
The strange thing is that it's only D&D players who imagine that invisible creatures become visible after attacking! Normal people(!) don't imagine this! Perseus donned the Cap of Invisibility and attacked The Medusa, but he didn't lose his invisibility in the process!
It's only a D&D thing, this 'lose invisibility after you attack', and only because
previous editions said that the spell ended as detailed in the spell description. Therefore, the
only spell description that is relevant in 5e is the 5e spell description, and
that says that it ends early if the target attacks or casts a spell,
both of which are game terms!
The sentence about 'if you are in any doubt if something counts as an attack' has a purpose, and that purpose is not only to say that that this list of things counts as an attack, but also to say that things
not on the list are
not an attack! If this were not the purpose of the sentence then it would be a total waste of ink!
It is
against reason to imagine that when the writer wrote the list of what counts as an attack as:-
* things with an attack roll
* things that specifically say they count as an attack even though they don't have an attack roll
...which is a useful list so that we can definitely know if something is an attack or not, and then imagine that the writer
meant to add a third item to the list:-
* errm, anything else you think is a bit attack-y
...because that would turn the list from something that definitely answers the question, "is this an attack, yes or no" into something that doesn't tell you the answer!
A 'normal' person who got hold of the Cap of Invisibility would not expect the Cap to stop working if you throw a grenade. Why? What has throwing something got to do with whatever magic makes you perfectly transparent?
D&D only has this for game balance; without it invisibility becomes too powerful for a 2nd level spell. It has nothing to do with any logical connection between 'attacking' and whether magic works.
One problem that previous editions had when their spell descriptions stated that 'attacking ends invisibility' is that they extended what 'attack' meant beyond what the game defined as an 'attack' into absurdity. Such absurdities included creatures who used a breath weapon on an area and if there was a hidden creature there then the breather lost invisibility and if the area was clear then they didn't. How does the spell know? Oh, you have to deliberately attack to lose invisibility, but if you accidentally hurt someone or hurt someone indirectly then you don't. Again, how does the spell know? Can it read your mind and your intentions, and make a judgement call? Spells are not sentient!
But good news, 5e has
completely solved any ambiguity, because instead of an ambiguously extended definition of 'attack' for this spell and this spell only, it uses the normal game definition (and it
is a game definition!) of 'attack' (and 'cast a spell'), and this does not include breath weapons or including an opponent in the area of
detect magic like it did in previous editions.
It is disingenuous to read a spell description that includes a game term and pretend that it
isn't a game term so that you can abuse 'natural language' and pretend that the
game rules say that you lose invisibility if you wear white socks with black shoes because it's an 'attack' against good taste!