1. Full file highlighting (fix the legacy todo "we should instead
highlight the whole file at once")
* Fix#24383
2. Correctly covert file content encoding
3. Remove dead code, split large for-loop into small functions/blocks to
make code maintainable