[Format] Fix detection of languages when reading from stdin (#79051)

The code cleanup in #74794 accidentally broke detection of languages by
reading file content from stdin, e.g. via `clang-format -dump-config - <
/path/to/filename`.

This PR adds unit and integration tests to reproduce the issue and adds
a fix.

Fixes: #79023
NOKEYCHECK=True
GitOrigin-RevId: d813af73f70f6b2fd41621d640cc35e595b9da4c
1 file changed