@@ -114,10 +114,8 @@ impl Connection {
114
114
/// ```
115
115
pub fn initialize_start ( & self ) -> Result < ( RequestId , serde_json:: Value ) , ProtocolError > {
116
116
loop {
117
- match self . receiver . recv ( ) {
118
- Ok ( Message :: Request ( req) ) if req. is_initialize ( ) => {
119
- return Ok ( ( req. id , req. params ) )
120
- }
117
+ break match self . receiver . recv ( ) {
118
+ Ok ( Message :: Request ( req) ) if req. is_initialize ( ) => Ok ( ( req. id , req. params ) ) ,
121
119
// Respond to non-initialize requests with ServerNotInitialized
122
120
Ok ( Message :: Request ( req) ) => {
123
121
let resp = Response :: new_err (
@@ -126,14 +124,11 @@ impl Connection {
126
124
format ! ( "expected initialize request, got {req:?}" ) ,
127
125
) ;
128
126
self . sender . send ( resp. into ( ) ) . unwrap ( ) ;
127
+ continue ;
129
128
}
130
- Ok ( msg) => {
131
- return Err ( ProtocolError ( format ! ( "expected initialize request, got {msg:?}" ) ) )
132
- }
129
+ Ok ( msg) => Err ( ProtocolError ( format ! ( "expected initialize request, got {msg:?}" ) ) ) ,
133
130
Err ( e) => {
134
- return Err ( ProtocolError ( format ! (
135
- "expected initialize request, got error: {e}"
136
- ) ) )
131
+ Err ( ProtocolError ( format ! ( "expected initialize request, got error: {e}" ) ) )
137
132
}
138
133
} ;
139
134
}
@@ -148,17 +143,14 @@ impl Connection {
148
143
let resp = Response :: new_ok ( initialize_id, initialize_result) ;
149
144
self . sender . send ( resp. into ( ) ) . unwrap ( ) ;
150
145
match & self . receiver . recv ( ) {
151
- Ok ( Message :: Notification ( n) ) if n. is_initialized ( ) => ( ) ,
146
+ Ok ( Message :: Notification ( n) ) if n. is_initialized ( ) => Ok ( ( ) ) ,
152
147
Ok ( msg) => {
153
- return Err ( ProtocolError ( format ! ( "expected Message::Notification , got: {msg:?}" , ) ) )
148
+ Err ( ProtocolError ( format ! ( r# "expected initialized notification , got: {msg:?}"# ) ) )
154
149
}
155
150
Err ( e) => {
156
- return Err ( ProtocolError ( format ! (
157
- "expected initialized notification, got error: {e}" ,
158
- ) ) )
151
+ Err ( ProtocolError ( format ! ( "expected initialized notification, got error: {e}" , ) ) )
159
152
}
160
153
}
161
- Ok ( ( ) )
162
154
}
163
155
164
156
/// Initialize the connection. Sends the server capabilities
0 commit comments