mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 10:48:55 +08:00
Do not indent after escaped newline in comment
We do something similar in fish_indent. This fixes the spurious indent after comments in share/completions/emerge.fish. See #7720
This commit is contained in:
parent
8b0b987993
commit
444c05dfb1
@ -1480,8 +1480,12 @@ static void test_indents() {
|
||||
1, "\nline2 \\", //
|
||||
1, "\n" //
|
||||
);
|
||||
add_test(&tests, //
|
||||
0, "echo # inline comment ending in \\", //
|
||||
0, "\nline" //
|
||||
);
|
||||
add_test(&tests, //
|
||||
0, "echo # comment ending in \\", //
|
||||
0, "# line comment ending in \\", //
|
||||
0, "\nline" //
|
||||
);
|
||||
add_test(&tests, //
|
||||
|
@ -717,6 +717,8 @@ std::vector<int> parse_util_compute_indents(const wcstring &src) {
|
||||
wcstring gap_text = src.substr(last_leaf_end, offset - last_leaf_end);
|
||||
size_t escaped_nl = gap_text.find(L"\\\n");
|
||||
if (escaped_nl == wcstring::npos) return;
|
||||
auto line_end = gap_text.begin() + escaped_nl;
|
||||
if (std::find(gap_text.begin(), line_end, L'#') != line_end) return;
|
||||
auto end = src.begin() + offset;
|
||||
auto newline = src.begin() + last_leaf_end + escaped_nl + 1;
|
||||
// The gap text might contain multiple newlines if there are multiple lines that
|
||||
|
Loading…
x
Reference in New Issue
Block a user