[geany/geany-plugins] adef49: Merge pull request #512 from eht16/spellcheck_underscore_word_sep_issue496
Frank Lanitz
git-noreply at xxxxx
Tue Jan 3 20:14:11 UTC 2017
Branch: refs/heads/master
Author: Frank Lanitz <frank at frank.uvena.de>
Committer: GitHub <noreply at github.com>
Date: Tue, 03 Jan 2017 20:14:11 UTC
Commit: adef494292950ab0953a8b62f7689425df8747f8
https://github.com/geany/geany-plugins/commit/adef494292950ab0953a8b62f7689425df8747f8
Log Message:
-----------
Merge pull request #512 from eht16/spellcheck_underscore_word_sep_issue496
Treat underscore as word seperator
Modified Paths:
--------------
spellcheck/src/speller.c
Modified: spellcheck/src/speller.c
29 lines changed, 24 insertions(+), 5 deletions(-)
===================================================================
@@ -205,6 +205,8 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number)
gint suggestions_found = 0;
gint wordchars_len;
gchar *wordchars;
+ gchar *underscore_in_wordchars = NULL;
+ gboolean wordchars_modified = FALSE;
g_return_val_if_fail(sc_speller_dict != NULL, 0);
g_return_val_if_fail(doc != NULL, 0);
@@ -218,9 +220,21 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number)
{
/* temporarily add "'" to the wordchars */
wordchars[wordchars_len] = '\'';
+ wordchars_modified = TRUE;
+ }
+ underscore_in_wordchars = strchr(wordchars, '_');
+ if (underscore_in_wordchars != NULL)
+ {
+ /* Temporarily remove underscore from the wordchars to treat
+ * it as a word seperator. Replace it by a "'" which we added already above. */
+ *underscore_in_wordchars = '\'';
+ wordchars_modified = TRUE;
+ }
+ if (wordchars_modified)
+ {
+ /* apply previously changed WORDCHARS setting */
scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars);
}
-
pos_start = sci_get_position_from_line(doc->editor->sci, line_number);
pos_end = sci_get_position_from_line(doc->editor->sci, line_number + 1);
@@ -242,10 +256,15 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number)
g_free(word);
}
- /* reset wordchars for the current document */
- wordchars[wordchars_len] = '\0';
- scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars);
-
+ if (wordchars_modified)
+ {
+ if (underscore_in_wordchars != NULL)
+ /* re-add underscore if we removed it above */
+ *underscore_in_wordchars = '_';
+ /* reset wordchars for the current document */
+ wordchars[wordchars_len] = '\0';
+ scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars);
+ }
g_free(wordchars);
return suggestions_found;
}
--------------
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