summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Mildenberger2023-03-18 19:33:17 +0000
committerPhilipp Mildenberger2023-05-18 19:48:32 +0000
commit1122928c2adef0a1c34e90d140c61f84beeb7418 (patch)
tree65ed74cdef29859b69e9c44feb85e4b29320078f
parentec2f9091a06d07a8c4faa7533b814bdf59e36c35 (diff)
Add method doc.supports_language_server for better readability
-rw-r--r--helix-term/src/application.rs7
-rw-r--r--helix-view/src/document.rs4
2 files changed, 6 insertions, 5 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 83473179..dbb873e0 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -702,7 +702,7 @@ impl Application {
let docs = self
.editor
.documents()
- .filter(|doc| doc.language_servers().any(|l| l.id() == server_id));
+ .filter(|doc| doc.supports_language_server(server_id));
// trigger textDocument/didOpen for docs that are already open
for doc in docs {
@@ -969,10 +969,7 @@ impl Application {
.editor
.documents_mut()
.filter_map(|doc| {
- if doc
- .language_servers()
- .any(|server| server.id() == server_id)
- {
+ if doc.supports_language_server(server_id) {
doc.clear_diagnostics(server_id);
doc.url()
} else {
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 4b075293..5fec3361 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -1456,6 +1456,10 @@ impl Document {
})
}
+ pub fn supports_language_server(&self, id: usize) -> bool {
+ self.language_servers().any(|l| l.id() == id)
+ }
+
pub fn diff_handle(&self) -> Option<&DiffHandle> {
self.diff_handle.as_ref()
}