Skip to content

Commit

Permalink
workspace code action
Browse files Browse the repository at this point in the history
  • Loading branch information
frederik-uni committed Aug 30, 2024
1 parent 14a62d7 commit 0d74f07
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargotom"
version = "0.9.0"
version = "0.10.0"
edition = "2021"

[dependencies]
Expand Down
16 changes: 16 additions & 0 deletions src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ impl LanguageServer for Backend {
store.find_crate_by_byte_offset_range(byte_offset_start, byte_offset_end)
{
let crate_name = &v.key.value;
if matches!(v.value, Value::NoContent) {
let start = store.byte_offset_to_position(v.key.range.end);
let action = CodeAction {
title: "Make Workspace dependency".to_string(),
kind: Some(CodeActionKind::QUICKFIX),
edit: Some(new_workspace_edit(
uri_.clone(),
vec![TextEdit::new(
Range::new(start, start),
" = { workspace = true }".to_string(),
)],
)),
..CodeAction::default()
};
actions.push(CodeActionOrCommand::CodeAction(action));
}
if let (Some(range), Some((version, _))) = (v.value.range(), v.get_version()) {
let start = store.byte_offset_to_position(range.start);
let end = store.byte_offset_to_position(range.end);
Expand Down

0 comments on commit 0d74f07

Please sign in to comment.