microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
108.85k stars 6.42k forks source link

Source code preview causes very slow TXT file preview in Explorer #29750

Open LesFerch opened 10 months ago

LesFerch commented 10 months ago

Microsoft PowerToys version

0.75.1

Installation method

Microsoft Store

Running as admin

Yes

Area(s) with issue?

File Explorer: Preview Pane

Steps to reproduce

Enable File Explorer add-ons Enable Source code files preview Enable Preview pane in Explorer Browse a folder and select a TXT file

Instead of the usual instantaneous preview, there is a green "Loading" progress bar for a second or two and then the file is previewed. This occurs even if it's only a 1 character test file. It's orders of magnitude slower than the default preview. It may be less noticeable on high-end rigs, but is painful on a basic laptop, like mine.

Theory: The delay is happening because the source code previewer is checking the file contents to determine what syntax colorizer to use.

Suggestion: Do not handle TXT files. Let Explorer's default previewer handle them. If a file has a TXT extension, it's perfectly OK to display it as plain uncolored text, regardless of content.

Alternative solution: Replace the preview code with faster code. There really should be no delay. For example, I use Notepad2, which syntax highlights all source code, and it's instantaneous on my laptop.

✔️ Expected Behavior

Instant preview of text files.

❌ Actual Behavior

Slow preview of text files.

Other Software

No response

rikmm commented 1 month ago

Had the exact same issue today. I was blaming the antivirus and Windows 11. Uninstalled the AV didn't change. Uninstalled powertoys, my explorer seems faster and previews are immediate. I suspect powertoys explorer extensions to slow down explorer even outside the preview pane.