minor: Simplify Document.language_id()

This commit is contained in:
Blaž Hrastnik 2022-06-07 00:11:08 +09:00
parent b14c258a2c
commit 3d9923969a
No known key found for this signature in database
GPG key ID: 1238B9C4AD889640

View file

@ -854,9 +854,11 @@ impl Document {
/// `language-server` configuration, or the document language if no
/// `language-id` has been specified.
pub fn language_id(&self) -> Option<&str> {
self.language_config()
.and_then(|config| config.language_server.as_ref())
.and_then(|lsp_config| lsp_config.language_id.as_deref())
self.language_config()?
.language_server
.as_ref()?
.language_id
.as_deref()
.or_else(|| Some(self.language()?.rsplit_once('.')?.1))
}