Skip to content

Commit 6df414f

Browse files
committed
Inverted the match logic to skip comments, attribute macros, and whitespace before the appropriate keywords.
1 parent 09da74a commit 6df414f

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

crates/ide-assists/src/handlers/extract_module.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,10 @@ impl Module {
382382
for (vis, syntax) in replacements {
383383
let item = syntax.children_with_tokens().find(|node_or_token| {
384384
match node_or_token.kind() {
385-
// We're looking for the start of functions, impls, structs, traits, and other documentable/attribute
386-
// macroable items that would have pub(crate) in front of it
387-
SyntaxKind::FN_KW
388-
| SyntaxKind::STRUCT_KW
389-
| SyntaxKind::ENUM_KW
390-
| SyntaxKind::TRAIT_KW
391-
| SyntaxKind::TYPE_KW
392-
| SyntaxKind::CONST_KW
393-
| SyntaxKind::MOD_KW => true,
394-
// If we didn't find a keyword, we want to cover the record fields in a struct
395-
SyntaxKind::NAME => true,
396-
// Otherwise, the token shouldn't have pub(crate) before it
397-
_ => false,
385+
// We're skipping comments, doc comments, and attribute macros that may precede the keyword
386+
// that the visibility should be placed before.
387+
SyntaxKind::COMMENT | SyntaxKind::ATTR | SyntaxKind::WHITESPACE => false,
388+
_ => true,
398389
}
399390
});
400391

0 commit comments

Comments
 (0)