Fix auto-rename ranges with special characters (#13719)
Release Notes: - Fixed ([#13551](https://github.com/zed-industries/zed/issues/13551)).
This commit is contained in:
parent
3a43adba00
commit
0eb26d29ee
1 changed files with 18 additions and 8 deletions
|
@ -3123,14 +3123,24 @@ impl Editor {
|
||||||
let anchor = snapshot.anchor_after(selection.end);
|
let anchor = snapshot.anchor_after(selection.end);
|
||||||
if !self.linked_edit_ranges.is_empty() {
|
if !self.linked_edit_ranges.is_empty() {
|
||||||
let start_anchor = snapshot.anchor_before(selection.start);
|
let start_anchor = snapshot.anchor_before(selection.start);
|
||||||
if let Some(ranges) =
|
|
||||||
self.linked_editing_ranges_for(start_anchor.text_anchor..anchor.text_anchor, cx)
|
let is_word_char = text.chars().next().map_or(true, |char| {
|
||||||
{
|
let scope = snapshot.language_scope_at(start_anchor.to_offset(&snapshot));
|
||||||
for (buffer, edits) in ranges {
|
let kind = char_kind(&scope, char);
|
||||||
linked_edits
|
|
||||||
.entry(buffer.clone())
|
kind == CharKind::Word
|
||||||
.or_default()
|
});
|
||||||
.extend(edits.into_iter().map(|range| (range, text.clone())));
|
|
||||||
|
if is_word_char {
|
||||||
|
if let Some(ranges) = self
|
||||||
|
.linked_editing_ranges_for(start_anchor.text_anchor..anchor.text_anchor, cx)
|
||||||
|
{
|
||||||
|
for (buffer, edits) in ranges {
|
||||||
|
linked_edits
|
||||||
|
.entry(buffer.clone())
|
||||||
|
.or_default()
|
||||||
|
.extend(edits.into_iter().map(|range| (range, text.clone())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue