Skip to content

Commit 8311d4e

Browse files
fruno-bulaxlpil
authored andcommitted
fix(language server): Omit label shorthand ':' in prepare_rename
1 parent c1dcaba commit 8311d4e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

compiler-core/src/language_server/engine.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,11 +645,16 @@ where
645645
}) if location.contains(byte_index) => match origin.map(|origin| origin.syntax) {
646646
Some(VariableSyntax::Generated) => None,
647647
Some(
648-
VariableSyntax::Variable { .. }
649-
| VariableSyntax::AssignmentPattern
650-
| VariableSyntax::LabelShorthand(_),
651-
)
652-
| None => success_response(location),
648+
VariableSyntax::Variable(label) | VariableSyntax::LabelShorthand(label),
649+
) => success_response(SrcSpan {
650+
start: location.start,
651+
end: label
652+
.len()
653+
.try_into()
654+
.map(|len: u32| location.start + len)
655+
.unwrap_or(location.end),
656+
}),
657+
Some(VariableSyntax::AssignmentPattern) | None => success_response(location),
653658
},
654659
Some(
655660
Referenced::ModuleValue {

compiler-core/src/language_server/tests/snapshots/gleam_core__language_server__tests__rename__rename_local_variable_label_shorthand_from_definition.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Wibble {
1111

1212
pub fn main() {
1313
let Wibble(wibble:) = todo
14-
↑▔▔▔▔▔
14+
↑▔▔▔▔▔
1515
wibble + 1
1616
}
1717

0 commit comments

Comments
 (0)