PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

Logpoints do not evaluate correctly

Open JustinGrote opened this issue 3 years ago • 5 comments

image

Expected: The actual value

JustinGrote avatar Feb 15 '22 00:02 JustinGrote

Is this only in Preview?

andyleejordan avatar Feb 16 '22 20:02 andyleejordan

@andschwa pretty sure but haven't fully tested, I know it used to work just fine, I've used it before.

JustinGrote avatar Feb 16 '22 21:02 JustinGrote

I think you might be remembering wrong. AFAIK this is just a string, so you'd need to use subexpression for properties.

Update: Tested in stable and 2021.8.0. No change and $($test.TestProperty) works as expected.

If anything I'd consider adding support for {} as $() since VSCode hardcodes the placeholder-text Message to log when breakpoint is hit. Expressions within {} are interpolated. 'Enter' to accept, 'esc' to cancel.. Unless that is customizable somehow.

fflaten avatar Aug 05 '22 08:08 fflaten

If {} is present it could just be replaced with $() before being sent to the evaluator. Good call on it being brought in as a string and not a scriptblock, wonder if there's a way to modify the placeholder text per-extension to be more clear on this.

JustinGrote avatar Aug 05 '22 19:08 JustinGrote

If {} is present it could just be replaced with $() before being sent to the evaluator.

Will likely have to use AST-parsing to not break expressions with scriptblocks, ex Logpoint reached. {($myList | ? { $_ }).Count} items in list. I've personally never used scriptblocks in them, but Murphy's law says someone is 🙂 Would that be too slow to be considered?

wonder if there's a way to modify the placeholder text per-extension to be more clear on this.

I can't really see a way to customize it without trying to override using localization, but I doubt we could change language pack depending on document language. I've submitted a feature request (microsoft/vscode#157324) for language-specific syntax in the placeholder-text.

fflaten avatar Aug 05 '22 20:08 fflaten