# Fix language detection when file name begins with a \`\.\` \(\#2833\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/bed0d1d529f9317f2d1e47e6a79c9fb7be6364a8)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: bed0d1d529f9317f2d1e47e6a79c9fb7be6364a8

Requested commit: bed0d1d529f9317f2d1e47e6a79c9fb7be6364a8

Commit: bed0d1d529f9317f2d1e47e6a79c9fb7be6364a8

Tree: 83ec7a4f6c5048d90b6a4071ab1c2731b165f0c4

Author: Joseph T\. Lyons

Committer: GitHub

## Message

```
Fix language detection when file name begins with a `.` (#2833)

I went to add in `zprofile` to the bash language config to get syntax
highlighting for it. After adding it in, Zed was still not highlighting
the file. I checked and saw that we are using `Path::extension()` in
`language_for_file()`, which [returns `None` when a file's name begins
with a
`.`](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.extension),
such as in the case of `.zprofile`. This PR adds a custom method, with
some tests, that just tries to grab the last component in the file name
if `Path::extension` returns `None`. Not sure if `ext` is the best name,
but I can't use `extension`.

Maybe this method should be called `extension_or_hidden_file_name()`?

Release Notes:

- Fixed a bug where language detection would fail for files starting
with `.` in their names.
- Added syntax highlighting for `.zprofile` files
```

## Parents

- [54ca5f1d449024923acd5ff93ff2e9d4663ced87](https://git.cafe/gitcafe/zed/commit/54ca5f1d449024923acd5ff93ff2e9d4663ced87?format=markdown)

- [c523ccc4c7cd5739e465a194a4b621840a1cd021](https://git.cafe/gitcafe/zed/commit/c523ccc4c7cd5739e465a194a4b621840a1cd021?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/bed0d1d529f9317f2d1e47e6a79c9fb7be6364a8?format=markdown)
