Branch: refs/heads/master Author: Nick Treleaven ntrel002@gmail.com Committer: GitHub noreply@github.com Date: Fri, 17 Feb 2023 20:46:49 UTC Commit: 00aaf374cb706032293f2834566a8d6e99cbfca6 https://github.com/geany/geany/commit/00aaf374cb706032293f2834566a8d6e99cbfc...
Log Message: ----------- Only insert multi-line comment continuation if previous line has it (#3392)
Don't insert * after new line in multi-line comment if previous line doesn't start with *
Fixes #3386.
Modified Paths: -------------- doc/geany.txt src/editor.c
Modified: doc/geany.txt 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -2217,7 +2217,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, no ``*`` will be added to the new line.
Autocomplete symbols When you start to type a symbol name, look for the full string to
Modified: src/editor.c 15 lines changed, 9 insertions(+), 6 deletions(-) =================================================================== @@ -3535,8 +3535,8 @@ static void auto_multiline(GeanyEditor *editor, gint cur_line) if (sci_get_style_at(sci, indent_pos) == style || indent_pos >= sci_get_length(sci)) { gchar *previous_line = sci_get_line(sci, cur_line - 1); - /* the type of comment, '*' (C/C++/Java), '+' and the others (D) */ - const gchar *continuation = "*"; + /* the type of comment, '*' (C/C++/Java), '+' D comment that nests */ + const gchar *continuation = (style == SCE_D_COMMENTNESTED) ? "+" : "*"; const gchar *whitespace = ""; /* to hold whitespace if needed */ gchar *result; gint len = strlen(previous_line); @@ -3569,10 +3569,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 + 1 == len || isspace(previous_line[i + 1])))) + { + // previous line isn't formatted so abort + g_free(previous_line); + return; + } result = g_strconcat(whitespace, continuation, " ", NULL); sci_add_text(sci, result); g_free(result);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).