aboutsummaryrefslogtreecommitdiff
path: root/crates/server
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server')
-rw-r--r--crates/server/src/main_loop/mod.rs28
-rw-r--r--crates/server/src/path_map.rs5
2 files changed, 29 insertions, 4 deletions
diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs
index 1fbcc7d1f..a8340df59 100644
--- a/crates/server/src/main_loop/mod.rs
+++ b/crates/server/src/main_loop/mod.rs
@@ -167,7 +167,10 @@ fn on_request(
167 dispatch::handle_request::<req::ExecuteCommand, _>(&mut req, |params, resp| { 167 dispatch::handle_request::<req::ExecuteCommand, _>(&mut req, |params, resp| {
168 io.send(RawMsg::Response(resp.into_response(Ok(None))?)); 168 io.send(RawMsg::Response(resp.into_response(Ok(None))?));
169 169
170 let world = world.snapshot(); 170 let world = world.snapshot({
171 let pm = path_map.clone();
172 move |id, path| pm.resolve(id, path)
173 });
171 let path_map = path_map.clone(); 174 let path_map = path_map.clone();
172 let sender = sender.clone(); 175 let sender = sender.clone();
173 pool.execute(move || { 176 pool.execute(move || {
@@ -234,7 +237,14 @@ fn on_notification(
234 mem_map.insert(file_id, None); 237 mem_map.insert(file_id, None);
235 world.change_file(file_id, Some(params.text_document.text)); 238 world.change_file(file_id, Some(params.text_document.text));
236 update_file_notifications_on_threadpool( 239 update_file_notifications_on_threadpool(
237 pool, world.snapshot(), path_map.clone(), sender.clone(), uri, 240 pool,
241 world.snapshot({
242 let pm = path_map.clone();
243 move |id, path| pm.resolve(id, path)
244 }),
245 path_map.clone(),
246 sender.clone(),
247 uri,
238 ); 248 );
239 Ok(()) 249 Ok(())
240 })?; 250 })?;
@@ -245,7 +255,14 @@ fn on_notification(
245 .text; 255 .text;
246 world.change_file(file_id, Some(text)); 256 world.change_file(file_id, Some(text));
247 update_file_notifications_on_threadpool( 257 update_file_notifications_on_threadpool(
248 pool, world.snapshot(), path_map.clone(), sender.clone(), params.text_document.uri, 258 pool,
259 world.snapshot({
260 let pm = path_map.clone();
261 move |id, path| pm.resolve(id, path)
262 }),
263 path_map.clone(),
264 sender.clone(),
265 params.text_document.uri,
249 ); 266 );
250 Ok(()) 267 Ok(())
251 })?; 268 })?;
@@ -281,7 +298,10 @@ fn handle_request_on_threadpool<R: req::ClientRequest>(
281) -> Result<()> 298) -> Result<()>
282{ 299{
283 dispatch::handle_request::<R, _>(req, |params, resp| { 300 dispatch::handle_request::<R, _>(req, |params, resp| {
284 let world = world.snapshot(); 301 let world = world.snapshot({
302 let pm = path_map.clone();
303 move |id, path| pm.resolve(id, path)
304 });
285 let path_map = path_map.clone(); 305 let path_map = path_map.clone();
286 let sender = sender.clone(); 306 let sender = sender.clone();
287 pool.execute(move || { 307 pool.execute(move || {
diff --git a/crates/server/src/path_map.rs b/crates/server/src/path_map.rs
index 2454ba05f..e198e165d 100644
--- a/crates/server/src/path_map.rs
+++ b/crates/server/src/path_map.rs
@@ -34,6 +34,11 @@ impl PathMap {
34 .as_path() 34 .as_path()
35 } 35 }
36 36
37 pub fn resolve(&self, id: FileId, relpath: &Path) -> Option<FileId> {
38 let path = self.get_path(id).join(relpath);
39 self.get_id(&path)
40 }
41
37 fn insert(&mut self, path: PathBuf, id: FileId) { 42 fn insert(&mut self, path: PathBuf, id: FileId) {
38 self.path2id.insert(path.clone(), id); 43 self.path2id.insert(path.clone(), id);
39 self.id2path.insert(id, path.clone()); 44 self.id2path.insert(id, path.clone());