[geany/geany-plugins] eb9b14: Merge pull request #449 from sardemff7/wip/addons-tasks
Frank Lanitz
git-noreply at xxxxx
Fri Jun 17 17:38:02 UTC 2016
Branch: refs/heads/master
Author: Frank Lanitz <frank at frank.uvena.de>
Committer: GitHub <noreply at github.com>
Date: Fri, 17 Jun 2016 17:38:02 UTC
Commit: eb9b14366da1beb42b6a5febe0ab9823486e2fb6
https://github.com/geany/geany-plugins/commit/eb9b14366da1beb42b6a5febe0ab9823486e2fb6
Log Message:
-----------
Merge pull request #449 from sardemff7/wip/addons-tasks
addons/tasks: Small improvments
Modified Paths:
--------------
addons/src/ao_tasks.c
Modified: addons/src/ao_tasks.c
50 lines changed, 30 insertions(+), 20 deletions(-)
===================================================================
@@ -558,38 +558,48 @@ static void create_task(AoTasks *t, GeanyDocument *doc, gint line, const gchar *
static void update_tasks_for_doc(AoTasks *t, GeanyDocument *doc)
{
- gint lines, line;
- gchar *line_buf, *display_name, *task_start;
+ gint lexer, lines, line, last_pos = 0, style;
+ gchar *line_buf, *display_name, *task_start, *closing_comment;
gchar **token;
AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(t);
if (doc->is_valid)
{
display_name = document_get_basename_for_display(doc, -1);
+ lexer = sci_get_lexer(doc->editor->sci);
lines = sci_get_line_count(doc->editor->sci);
for (line = 0; line < lines; line++)
{
- line_buf = g_strstrip(sci_get_line(doc->editor->sci, line));
- token = priv->tokens;
- while (*token != NULL)
+ line_buf = sci_get_line(doc->editor->sci, line);
+ for (token = priv->tokens; *token != NULL; ++token)
{
- if (!EMPTY(*token) && (task_start = strstr(line_buf, *token)) != NULL)
- {
- /* skip the token and additional whitespace */
- task_start += strlen(*token);
- while (*task_start == ' ' || *task_start == ':')
- task_start++;
- /* reset task_start in case there is no text following */
- if (EMPTY(task_start))
- task_start = line_buf;
- /* create the task */
- create_task(t, doc, line, *token, line_buf, task_start, display_name);
- /* if we found a token, continue on next line */
- break;
- }
- token++;
+ if (EMPTY(*token))
+ continue;
+ if ((task_start = strstr(line_buf, *token)) == NULL)
+ continue;
+ style = sci_get_style_at(doc->editor->sci, last_pos + (task_start - line_buf));
+ if (!highlighting_is_comment_style(lexer, style))
+ continue;
+
+ /* skip the token and additional whitespace */
+ task_start = strstr(g_strstrip(line_buf), *token) + strlen(*token);
+ while (*task_start == ' ' || *task_start == ':')
+ task_start++;
+ /* reset task_start in case there is no text following */
+ if (EMPTY(task_start))
+ task_start = line_buf;
+ else if ((EMPTY(doc->file_type->comment_single) ||
+ strstr(line_buf, doc->file_type->comment_single) == NULL) &&
+ !EMPTY(doc->file_type->comment_close) &&
+ (closing_comment = strstr(task_start, doc->file_type->comment_close)) != NULL)
+ *closing_comment = '\0';
+ /* create the task */
+ create_task(t, doc, line, *token, line_buf, task_start, display_name);
+ /* if we found a token, continue on next line */
+ break;
}
g_free(line_buf);
+ last_pos = sci_get_line_end_position(doc->editor->sci, line) + 1;
}
g_free(display_name);
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list