[geany/geany-plugins] 4a77ba: Merge pull request #322 from eht16/320_fix_single_quote_detection
Frank Lanitz
git-noreply at xxxxx
Wed Jan 6 10:02:37 UTC 2016
Branch: refs/heads/master
Author: Frank Lanitz <frank at frank.uvena.de>
Committer: Frank Lanitz <frank at frank.uvena.de>
Date: Wed, 06 Jan 2016 10:02:37 UTC
Commit: 4a77ba2d627ec7f25586910d17fba12dd6aed87b
https://github.com/geany/geany-plugins/commit/4a77ba2d627ec7f25586910d17fba12dd6aed87b
Log Message:
-----------
Merge pull request #322 from eht16/320_fix_single_quote_detection
Improve detection of English contractions and other use of single quotes
Modified Paths:
--------------
spellcheck/src/speller.c
Modified: spellcheck/src/speller.c
21 lines changed, 20 insertions(+), 1 deletions(-)
===================================================================
@@ -203,13 +203,28 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number, const gchar *
{
gint pos_start, pos_end;
gint wstart, wend;
- GString *str;
gint suggestions_found = 0;
+ gint wordchars_len;
+ gchar *wordchars_orig;
+ GString *str;
g_return_val_if_fail(sc_speller_dict != NULL, 0);
g_return_val_if_fail(doc != NULL, 0);
g_return_val_if_fail(line != NULL, 0);
+ /* add ' (single quote) temporarily to wordchars
+ * to be able to check for "doesn't", "isn't" and similar */
+ wordchars_len = scintilla_send_message(doc->editor->sci, SCI_GETWORDCHARS, 0, 0);
+ wordchars_orig = g_malloc0(wordchars_len + 1);
+ scintilla_send_message(doc->editor->sci, SCI_GETWORDCHARS, 0, (sptr_t)wordchars_orig);
+ if (! strchr(wordchars_orig, '\''))
+ {
+ GString *wordchars_new = g_string_new(wordchars_orig);
+ g_string_append_c(wordchars_new, '\'');
+ scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars_new->str);
+ g_string_free(wordchars_new, TRUE);
+ }
+
str = g_string_sized_new(256);
pos_start = sci_get_position_from_line(doc->editor->sci, line_number);
@@ -233,6 +248,10 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number, const gchar *
pos_start = wend + 1;
}
+ /* reset wordchars for the current document */
+ scintilla_send_message(doc->editor->sci, SCI_SETWORDCHARS, 0, (sptr_t)wordchars_orig);
+
+ g_free(wordchars_orig);
g_string_free(str, TRUE);
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