@@ -9,9 +9,7 @@ use helix_lsp::LanguageServerId;
9
9
use helix_view:: document:: Mode ;
10
10
use helix_view:: events:: { DiagnosticsDidChange , DocumentDidChange , DocumentDidOpen } ;
11
11
use helix_view:: handlers:: diagnostics:: DiagnosticEvent ;
12
- use helix_view:: handlers:: lsp:: {
13
- PullDiagnosticsForDocumentsEvent , PullDiagnosticsForLanguageServersEvent ,
14
- } ;
12
+ use helix_view:: handlers:: lsp:: PullDiagnosticsForLanguageServersEvent ;
15
13
use helix_view:: handlers:: Handlers ;
16
14
use helix_view:: { DocumentId , Editor } ;
17
15
use tokio:: time:: Instant ;
@@ -54,18 +52,24 @@ pub(super) fn register_hooks(handlers: &Handlers) {
54
52
Ok ( ( ) )
55
53
} ) ;
56
54
57
- let tx = handlers. pull_diagnostics_for_documents . clone ( ) ;
58
55
register_hook ! ( move |event: & mut DocumentDidOpen <' _>| {
59
56
if event
60
57
. doc
61
58
. has_language_server_with_feature( LanguageServerFeature :: PullDiagnostics )
62
59
{
63
- send_blocking(
64
- & tx,
65
- PullDiagnosticsForDocumentsEvent {
66
- document_id: event. doc. id( ) ,
67
- } ,
68
- ) ;
60
+ let document_id = event. doc. id( ) ;
61
+ job:: dispatch_blocking( move |editor, _| {
62
+ let Some ( doc) = editor. document_mut( document_id) else {
63
+ return ;
64
+ } ;
65
+
66
+ let language_servers =
67
+ doc. language_servers_with_feature( LanguageServerFeature :: PullDiagnostics ) ;
68
+
69
+ for language_server in language_servers {
70
+ pull_diagnostics_for_document( doc, language_server) ;
71
+ }
72
+ } )
69
73
}
70
74
71
75
Ok ( ( ) )
@@ -84,17 +88,6 @@ impl PullDiagnosticsForLanguageServersHandler {
84
88
}
85
89
}
86
90
}
87
- pub ( super ) struct PullDiagnosticsForDocumentsHandler {
88
- document_ids : HashSet < DocumentId > ,
89
- }
90
-
91
- impl PullDiagnosticsForDocumentsHandler {
92
- pub fn new ( ) -> PullDiagnosticsForDocumentsHandler {
93
- PullDiagnosticsForDocumentsHandler {
94
- document_ids : [ ] . into ( ) ,
95
- }
96
- }
97
- }
98
91
99
92
impl helix_event:: AsyncHook for PullDiagnosticsForLanguageServersHandler {
100
93
type Event = PullDiagnosticsForLanguageServersEvent ;
@@ -116,41 +109,6 @@ impl helix_event::AsyncHook for PullDiagnosticsForLanguageServersHandler {
116
109
}
117
110
}
118
111
119
- impl helix_event:: AsyncHook for PullDiagnosticsForDocumentsHandler {
120
- type Event = PullDiagnosticsForDocumentsEvent ;
121
-
122
- fn handle_event (
123
- & mut self ,
124
- event : Self :: Event ,
125
- _: Option < tokio:: time:: Instant > ,
126
- ) -> Option < tokio:: time:: Instant > {
127
- self . document_ids . insert ( event. document_id ) ;
128
- Some ( Instant :: now ( ) + Duration :: from_millis ( 50 ) )
129
- }
130
-
131
- fn finish_debounce ( & mut self ) {
132
- let document_ids = self . document_ids . clone ( ) ;
133
- job:: dispatch_blocking ( move |editor, _| {
134
- pull_diagnostics_for_documents ( editor, document_ids)
135
- } )
136
- }
137
- }
138
-
139
- fn pull_diagnostics_for_documents ( editor : & mut Editor , document_ids : HashSet < DocumentId > ) {
140
- for document_id in document_ids {
141
- let Some ( doc) = editor. document_mut ( document_id) else {
142
- return ;
143
- } ;
144
-
145
- let language_servers =
146
- doc. language_servers_with_feature ( LanguageServerFeature :: PullDiagnostics ) ;
147
-
148
- for language_server in language_servers {
149
- pull_diagnostics_for_document ( doc, language_server) ;
150
- }
151
- }
152
- }
153
-
154
112
fn pull_diagnostic_for_language_servers (
155
113
editor : & mut Editor ,
156
114
language_server_ids : HashSet < LanguageServerId > ,
@@ -209,7 +167,7 @@ fn handle_pull_diagnostics_response(
209
167
response : lsp:: DocumentDiagnosticReport ,
210
168
server_id : LanguageServerId ,
211
169
uri : Uri ,
212
- document_id : helix_view :: DocumentId ,
170
+ document_id : DocumentId ,
213
171
) {
214
172
let Some ( doc) = editor. document_mut ( document_id) else {
215
173
return ;
@@ -263,7 +221,7 @@ fn add_diagnostics_to_editor(
263
221
264
222
fn handle_document_diagnostic_report_kind (
265
223
editor : & mut Editor ,
266
- document_id : helix_view :: DocumentId ,
224
+ document_id : DocumentId ,
267
225
report : Option < HashMap < lsp:: Url , lsp:: DocumentDiagnosticReportKind > > ,
268
226
server_id : LanguageServerId ,
269
227
) {
0 commit comments