|
|
@ -1826,18 +1826,14 @@ fn open(cx: &mut Context, open: Open) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// insert newlines after this index for both Above and Below variants
|
|
|
|
// insert newlines after this index for both Above and Below variants
|
|
|
|
let linend_index = doc.text().line_to_char(line).saturating_sub(
|
|
|
|
let line_end_index = rope_end_without_line_ending(&doc.text().slice(..));
|
|
|
|
get_line_ending(&doc.text().line(line))
|
|
|
|
|
|
|
|
.map(|le| le.len_chars())
|
|
|
|
|
|
|
|
.unwrap_or(0),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: share logic with insert_newline for indentation
|
|
|
|
// TODO: share logic with insert_newline for indentation
|
|
|
|
let indent_level = indent::suggested_indent_for_pos(
|
|
|
|
let indent_level = indent::suggested_indent_for_pos(
|
|
|
|
doc.language_config(),
|
|
|
|
doc.language_config(),
|
|
|
|
doc.syntax(),
|
|
|
|
doc.syntax(),
|
|
|
|
text,
|
|
|
|
text,
|
|
|
|
linend_index,
|
|
|
|
line_end_index,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
let indent = doc.indent_unit().repeat(indent_level);
|
|
|
|
let indent = doc.indent_unit().repeat(indent_level);
|
|
|
@ -1851,7 +1847,7 @@ fn open(cx: &mut Context, open: Open) {
|
|
|
|
let pos = if line == 0 {
|
|
|
|
let pos = if line == 0 {
|
|
|
|
0 // Required since text will have a min len of 1 (\n)
|
|
|
|
0 // Required since text will have a min len of 1 (\n)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
offs + linend_index + 1
|
|
|
|
offs + line_end_index + 1
|
|
|
|
};
|
|
|
|
};
|
|
|
|
for i in 0..count {
|
|
|
|
for i in 0..count {
|
|
|
|
// pos -> beginning of reference line,
|
|
|
|
// pos -> beginning of reference line,
|
|
|
@ -1862,7 +1858,7 @@ fn open(cx: &mut Context, open: Open) {
|
|
|
|
|
|
|
|
|
|
|
|
offs += text.chars().count();
|
|
|
|
offs += text.chars().count();
|
|
|
|
|
|
|
|
|
|
|
|
(linend_index, linend_index, Some(text.into()))
|
|
|
|
(line_end_index, line_end_index, Some(text.into()))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
|
|
|
|
transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
|
|
|
|