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
This commit is contained in:
commit
bed0d1d529
3 changed files with 38 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
name = "Shell Script"
|
||||
path_suffixes = ["sh", "bash", "bashrc", "bash_profile", "bash_aliases", "bash_logout", "profile", "zsh", "zshrc", "zshenv", "zsh_profile", "zsh_aliases", "zsh_histfile", "zlogin"]
|
||||
path_suffixes = ["sh", "bash", "bashrc", "bash_profile", "bash_aliases", "bash_logout", "profile", "zsh", "zshrc", "zshenv", "zsh_profile", "zsh_aliases", "zsh_histfile", "zlogin", "zprofile"]
|
||||
line_comment = "# "
|
||||
first_line_pattern = "^#!.*\\b(?:ba|z)?sh\\b"
|
||||
brackets = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue