…doesn't start with *
Fixes #3386.
Note: This was already the case when the previous line is blank, but a * was inserted when it is not blank. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3392
-- Commit Summary --
* Don't insert * after new line in multi-line comment if previous line doesn't start with *
-- File Changes --
M doc/geany.txt (3) M src/editor.c (15)
-- Patch Links --
https://github.com/geany/geany/pull/3392.patch https://github.com/geany/geany/pull/3392.diff
@techee commented on this pull request.
@@ -3526,10 +3526,13 @@ static void auto_multiline(GeanyEditor *editor, gint cur_line)
{ /* we are on the second line of a multi line comment, so we have to insert white space */ whitespace = " "; } - - if (style == SCE_D_COMMENTNESTED) - continuation = "+"; /* for nested comments in D */ - + else if (!(g_str_has_prefix(previous_line + i, continuation) &&
I'd just suggest inverting the condition (i.e. removing the initial `!`) and adding the 3 lines after this block inside the block. This way you avoid the duplicated `g_free(previous_line);` and the extra `return`.
@techee commented on this pull request.
@@ -3526,10 +3526,13 @@ static void auto_multiline(GeanyEditor *editor, gint cur_line)
{ /* we are on the second line of a multi line comment, so we have to insert white space */ whitespace = " "; } - - if (style == SCE_D_COMMENTNESTED) - continuation = "+"; /* for nested comments in D */ - + else if (!(g_str_has_prefix(previous_line + i, continuation) &&
Apart from that the PR looks fine to me and is useful, I also did run into this issue in the past.
@ntrel commented on this pull request.
@@ -3526,10 +3526,13 @@ static void auto_multiline(GeanyEditor *editor, gint cur_line)
{ /* we are on the second line of a multi line comment, so we have to insert white space */ whitespace = " "; } - - if (style == SCE_D_COMMENTNESTED) - continuation = "+"; /* for nested comments in D */ - + else if (!(g_str_has_prefix(previous_line + i, continuation) &&
That would break the first if clause before the else if on this line.
@techee commented on this pull request.
@@ -3526,10 +3526,13 @@ static void auto_multiline(GeanyEditor *editor, gint cur_line)
{ /* we are on the second line of a multi line comment, so we have to insert white space */ whitespace = " "; } - - if (style == SCE_D_COMMENTNESTED) - continuation = "+"; /* for nested comments in D */ - + else if (!(g_str_has_prefix(previous_line + i, continuation) &&
Ah, right, sorry, I didn't think about that.
@ntrel commented on this pull request.
@@ -3526,10 +3526,13 @@ static void auto_multiline(GeanyEditor *editor, gint cur_line)
{ /* we are on the second line of a multi line comment, so we have to insert white space */ whitespace = " "; } - - if (style == SCE_D_COMMENTNESTED) - continuation = "+"; /* for nested comments in D */ - + else if (!(g_str_has_prefix(previous_line + i, continuation) &&
No problem, thanks for reviewing.
@elextr commented on this pull request.
@@ -2208,7 +2208,8 @@ Automatic continuation multi-line comments
*
on the next line with the correct indentation based on the previous line, - as long as the multi-line is not closed by ``*/``. + as long as the multi-line is not closed by ``*/``. If the previous line + has no ``*`` prefix, the new line will not be changed.
Suggest "the new line will not be changed" s/b "no ``*`` will be added to the new line" just to be explicit
@ntrel commented on this pull request.
@@ -2208,7 +2208,8 @@ Automatic continuation multi-line comments
*
on the next line with the correct indentation based on the previous line, - as long as the multi-line is not closed by ``*/``. + as long as the multi-line is not closed by ``*/``. If the previous line + has no ``*`` prefix, the new line will not be changed.
```suggestion has no ``*`` prefix, no ``*`` will be added to the new line. ```
@ntrel pushed 1 commit.
a21ad8df2e9370ac7c3f233a3204724483e9aa8e Tweak wording
@b4n approved this pull request.
Looks good and works well :+1:
Merged #3392 into master.
github-comments@lists.geany.org