Skip to content

Commit 3b6274f

Browse files
JeanMertzautozimu
authored andcommitted
add CreateFile support in apply_WorkspaceEdit
`ResourceOp::Rename` and `ResourceOp::Delete` are not yet implemented.
1 parent 869847d commit 3b6274f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/language_server_protocol.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,11 @@ impl LanguageClient {
251251
}
252252

253253
fn apply_WorkspaceEdit(&self, edit: &WorkspaceEdit) -> Fallible<()> {
254+
use self::{DocumentChangeOperation::*, ResourceOp::*};
255+
254256
debug!("Begin apply WorkspaceEdit: {:?}", edit);
255-
let filename = self.vim()?.get_filename(&Value::Null)?;
256-
let position = self.vim()?.get_position(&Value::Null)?;
257+
let mut filename = self.vim()?.get_filename(&Value::Null)?;
258+
let mut position = self.vim()?.get_position(&Value::Null)?;
257259

258260
if let Some(ref changes) = edit.document_changes {
259261
match changes {
@@ -264,10 +266,19 @@ impl LanguageClient {
264266
}
265267
DocumentChanges::Operations(ref ops) => {
266268
for op in ops {
267-
if let DocumentChangeOperation::Edit(ref e) = op {
268-
self.apply_TextEdits(&e.text_document.uri.filepath()?, &e.edits)?;
269+
match op {
270+
Edit(ref e) => {
271+
self.apply_TextEdits(&e.text_document.uri.filepath()?, &e.edits)?
272+
}
273+
Op(ref rop) => match rop {
274+
Create(file) => {
275+
filename = file.uri.filepath()?.to_string_lossy().into_owned();
276+
position = Position::default();
277+
}
278+
Rename(_file) => bail!("file renaming not yet supported."),
279+
Delete(_file) => bail!("file deletion not yet supported."),
280+
},
269281
}
270-
// TODO: handle ResourceOp.
271282
}
272283
}
273284
}

0 commit comments

Comments
 (0)