Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: extract mod to file should respect path attribute
  • Loading branch information
Young-Flash committed May 12, 2024
commit 0c13f0cd5bbbd229b1d75e095d00f5c3383ec1ff
15 changes: 12 additions & 3 deletions crates/ide-assists/src/handlers/move_module_to_file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::iter;

use ast::edit::IndentLevel;
use hir::HasAttrs;
use ide_db::base_db::AnchoredPathBuf;
use itertools::Itertools;
use stdx::format_to;
Expand Down Expand Up @@ -50,9 +51,17 @@ pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext<'_>) ->
|builder| {
let path = {
let mut buf = String::from("./");
match parent_module.name(ctx.db()) {
Some(name) if !parent_module.is_mod_rs(ctx.db()) => {
format_to!(buf, "{}/", name.display(ctx.db()))
let db = ctx.db();
match parent_module.name(db) {
Some(name)
if !parent_module.is_mod_rs(db)
&& parent_module
.attrs(db)
.by_key("path")
.string_value_unescape()
.is_none() =>
{
format_to!(buf, "{}/", name.display(db))
}
_ => (),
}
Expand Down