Cherry-picked keymap ui: Fix remove key mapping bug (#34683) Release Notes: - N/A --------- Co-authored-by: Ben Kunkle <ben@zed.dev> Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Co-authored-by: Ben Kunkle <ben@zed.dev>
This commit is contained in:
parent
3f305fa805
commit
234a4f86ba
2 changed files with 45 additions and 2 deletions
|
@ -190,6 +190,7 @@ fn replace_value_in_json_text(
|
|||
}
|
||||
}
|
||||
|
||||
let mut removed_comma = false;
|
||||
// Look backward for a preceding comma first
|
||||
let preceding_text = text.get(0..removal_start).unwrap_or("");
|
||||
if let Some(comma_pos) = preceding_text.rfind(',') {
|
||||
|
@ -197,10 +198,12 @@ fn replace_value_in_json_text(
|
|||
let between_comma_and_key = text.get(comma_pos + 1..removal_start).unwrap_or("");
|
||||
if between_comma_and_key.trim().is_empty() {
|
||||
removal_start = comma_pos;
|
||||
removed_comma = true;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(remaining_text) = text.get(existing_value_range.end..) {
|
||||
if let Some(remaining_text) = text.get(existing_value_range.end..)
|
||||
&& !removed_comma
|
||||
{
|
||||
let mut chars = remaining_text.char_indices();
|
||||
while let Some((offset, ch)) = chars.next() {
|
||||
if ch == ',' {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue