PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Add .log support to Monaco preview handler

Open Eagle3386 opened this issue 1 year ago • 13 comments

Summary of the Pull Request

PR Checklist

  • [X] Closes: #17506
  • [X] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • [X] Tests: Added/updated and all pass (none added/updated, but all pass)
  • [-] Localization: All end user facing strings can be localized
  • [-] Dev docs: Added/updated
  • [-] New binaries: Added on the required places
  • [-] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Adds .log file extension to monaco_languages.json as supported plaintext file.

Validation Steps Performed

Rather small addition, hence added the extension locally (via Registry) & immediately noticed succeeding file preview.

Eagle3386 avatar Oct 20 '22 12:10 Eagle3386

What do you think about the additional log names ".err" and (possibly more conflicting) ".out"?

GitMensch avatar Oct 20 '22 13:10 GitMensch

Missing feedback from @crutkas or @Aaron-Junker within the linked issue made me focus on .log.

In addition to that, your "possibly more conflicting" hint fueled my believe that error and/or general output should rather be "redirected" into error.log & output.log respectively even more.

Ultimately, I'd suggest using .log as a "catch-all" logging file type & a file's actual name, i. e. everything left to the last ., for stating what content (type) such log files hold.

Eagle3386 avatar Oct 20 '22 13:10 Eagle3386

I see. Still suggest to add ".err" ;-)

GitMensch avatar Oct 20 '22 14:10 GitMensch

@Aaron-Junker:

monaco_languages.json gets suto-generated. You have to add another handler like in

https://github.com/microsoft/PowerToys/blob/db191b8b75ad456d5eb94eaa0aa0c7b59ecec900/src/modules/previewpane/MonacoPreviewHandler/monacoSpecialLanguages.js#L8

Just to get you right:

  1. I have to undo my changes inside monaco_languages.json?
  2. Register a new handler despite there's no such thing as syntax highlighting for .log files & plaintext .txt files are already handled without such a custom handler?
  3. There's no simple "register .log as another plaintext file type" change possible?

Eagle3386 avatar Nov 01 '22 16:11 Eagle3386

@stefansjfw:

@Aaron-Junker I'm leaving this to you :) Good catch

May I ask you to remove your change request then? Because once I solved Aaron's request, yours seems to still block my PR. Or am I getting something wrong here?

Eagle3386 avatar Nov 01 '22 16:11 Eagle3386

@Aaron-Junker:

monaco_languages.json gets suto-generated. You have to add another handler like in

https://github.com/microsoft/PowerToys/blob/db191b8b75ad456d5eb94eaa0aa0c7b59ecec900/src/modules/previewpane/MonacoPreviewHandler/monacoSpecialLanguages.js#L8

Just to get you right:

  1. I have to undo my changes inside monaco_languages.json?
  2. Register a new handler despite there's no such thing as syntax highlighting for .log files & plaintext .txt files are already handled without such a custom handler?
  3. There's no simple "register .log as another plaintext file type" change possible?
  1. Yes.
  2. Yes. And then you have to regenerate monaco_languages.json like described here: https://github.com/microsoft/PowerToys/blob/main/doc/devdocs/modules/powerpreview/monaco/readme.md

Aaron-Junker avatar Nov 01 '22 17:11 Aaron-Junker

Alright, doin' some rocket science then - back in a day or two, keep your fingers crossed! 🥳

Eagle3386 avatar Nov 01 '22 17:11 Eagle3386

@Aaron-Junker Done with the changes, but IMHO this could've been done way easier & faster by just stating:

  1. Add ,{"id":"logExt","extensions":[".log"]} to monaco_languages.json.
  2. Add registerAdditionalLanguage("logExt", [".log"], "log", monaco) to monacoSpecialLanguages.js, replace a wrong <tab> char with 4 spaces, remove a doubled trailing empty line in there, too & you're done.

This way, I'd have been much quicker getting this done & hence the preview handler supporting log files, too. Anyway, hope everything is well now - if not, please tell me right away & I'll fix it ASAP. :)

Eagle3386 avatar Nov 01 '22 19:11 Eagle3386

@Aaron-Junker The run failed due to some NuGet plugin error on Azure DevOps side, i. e. beyond my control - would you mind, getting the appropriate person to fix that & tell me how to re-trigger a run?

Eagle3386 avatar Nov 05 '22 08:11 Eagle3386

/azp run

Aaron-Junker avatar Nov 05 '22 08:11 Aaron-Junker

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Nov 05 '22 08:11 azure-pipelines[bot]

@Aaron-Junker Run completed, checks passed, LGTY?

Eagle3386 avatar Nov 08 '22 16:11 Eagle3386

@Aaron-Junker I'm leaving this to you :) Good catch

@stefansjfw since Aaron approved it & you stated that, you'll be leaving this to him, would you mind adding your approval, too? Because GitHub tells me it won't merge until you approved, too…

Eagle3386 avatar Nov 09 '22 18:11 Eagle3386

Thanks a lot for the contribution!

jaimecbernardo avatar Nov 14 '22 18:11 jaimecbernardo