Hi!
I've just been noticing that the Prompt for Snippet action seems to add an extra newline at the end of the outputted result if the prompt ends with a full line %Ask%. The extra newline is added regardless of the predicted number of lines in the %Ask% (%Ask%, %Ask1% and %Ask20% all give the same result, as seen in examples #1–3 in the test macro below).
In examples where the prompt does not end with a full line %Ask% there is no extra trailing newline added to the result (as seen in examples #6–7 in the test macro below).
When adding one or more newlines to the end of the inputted text, the result returns with the correct number of newlines, even when the prompt ends with a full line %Ask% (as in examples #4–5 in the test macro below).
To me this does not seem like expected behaviour
Test Macro:
Prompt for snippet — Last full line %Ask% seems to add extra newline.kmmacros (8.3 KB)
(KM v11.0.4)
Macro Image
@peternlewis, tagging you here to make sure you've at least seen these observations I've made. Obviously not a big glaring issue. But to me it seems like an inconsistency, and a bit buggy.
This inconsistency can be an issue when one wants to reliably process the text output from a snippet ending with a full line %Ask%.
I noticed this behavior when I where using the Prompt for snippet to fill in text that ended with a very deliberate number of empty lines. As things are now I could not differentiate between zero or one empty line.
This could obviously be worked around. But still I thought I'd report it
There is no bug here, this is working as designed.
There is no inconsistency once you consider that a multi-line Ask, that is an Ask token on a line by itself, always processes as a set of lines ending in a newline, the only exception being no characters at all which remain no characters at all.
So any non-empty multi-line Ask token result will always end in a newline character, either the one you type, or one will be added, so that the result is a sequence of lines with line ending characters.