vim: Copy comment to new lines with o/O (#19766)
Co-Authored-By: Kurt Wolf <kurtwolfbuilds@gmail.com> Closes: #4691 Closes #ISSUE Release Notes: - vim: o/O now respect `extend_comment_on_newline`
This commit is contained in:
parent
98d2e5fe73
commit
78ed0c9312
5 changed files with 73 additions and 16 deletions
|
@ -2862,6 +2862,30 @@ impl MultiBufferSnapshot {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn indent_and_comment_for_line(&self, row: MultiBufferRow, cx: &AppContext) -> String {
|
||||
let mut indent = self.indent_size_for_line(row).chars().collect::<String>();
|
||||
|
||||
if self.settings_at(0, cx).extend_comment_on_newline {
|
||||
if let Some(language_scope) = self.language_scope_at(Point::new(row.0, 0)) {
|
||||
let delimiters = language_scope.line_comment_prefixes();
|
||||
for delimiter in delimiters {
|
||||
if *self
|
||||
.chars_at(Point::new(row.0, indent.len() as u32))
|
||||
.take(delimiter.chars().count())
|
||||
.collect::<String>()
|
||||
.as_str()
|
||||
== **delimiter
|
||||
{
|
||||
indent.push_str(&delimiter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
indent
|
||||
}
|
||||
|
||||
pub fn prev_non_blank_row(&self, mut row: MultiBufferRow) -> Option<MultiBufferRow> {
|
||||
while row.0 > 0 {
|
||||
row.0 -= 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue