fix: extract mod to file should respect path attribute
This commit is contained in:
parent
48bcef3a32
commit
fafcc77855
@ -1,6 +1,7 @@
|
|||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use ast::edit::IndentLevel;
|
use ast::edit::IndentLevel;
|
||||||
|
use hir::HasAttrs;
|
||||||
use ide_db::base_db::AnchoredPathBuf;
|
use ide_db::base_db::AnchoredPathBuf;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
@ -50,9 +51,17 @@ pub(crate) fn move_module_to_file(acc: &mut Assists, ctx: &AssistContext<'_>) ->
|
|||||||
|builder| {
|
|builder| {
|
||||||
let path = {
|
let path = {
|
||||||
let mut buf = String::from("./");
|
let mut buf = String::from("./");
|
||||||
match parent_module.name(ctx.db()) {
|
let db = ctx.db();
|
||||||
Some(name) if !parent_module.is_mod_rs(ctx.db()) => {
|
match parent_module.name(db) {
|
||||||
format_to!(buf, "{}/", name.display(ctx.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))
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user