Avoid maintaining indent size as state on buffers
Indent size is still hard-coded, but it's now controlled by the editor and not the buffer. Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
parent
e21f90fec5
commit
664f17f92b
4 changed files with 51 additions and 45 deletions
|
@ -287,6 +287,8 @@ impl MultiBuffer {
|
|||
S: ToOffset,
|
||||
T: Into<String>,
|
||||
{
|
||||
let indent_size = crate::INDENT_SIZE;
|
||||
|
||||
if self.buffers.borrow().is_empty() {
|
||||
return;
|
||||
}
|
||||
|
@ -298,7 +300,7 @@ impl MultiBuffer {
|
|||
.map(|range| range.start.to_offset(&snapshot)..range.end.to_offset(&snapshot));
|
||||
return buffer.update(cx, |buffer, cx| {
|
||||
if autoindent {
|
||||
buffer.edit_with_autoindent(ranges, new_text, cx);
|
||||
buffer.edit_with_autoindent(ranges, new_text, indent_size, cx);
|
||||
} else {
|
||||
buffer.edit(ranges, new_text, cx);
|
||||
}
|
||||
|
@ -394,8 +396,8 @@ impl MultiBuffer {
|
|||
}
|
||||
|
||||
if autoindent {
|
||||
buffer.edit_with_autoindent(deletions, "", cx);
|
||||
buffer.edit_with_autoindent(insertions, new_text.clone(), cx);
|
||||
buffer.edit_with_autoindent(deletions, "", indent_size, cx);
|
||||
buffer.edit_with_autoindent(insertions, new_text.clone(), indent_size, cx);
|
||||
} else {
|
||||
buffer.edit(deletions, "", cx);
|
||||
buffer.edit(insertions, new_text.clone(), cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue