@@ -198,13 +198,28 @@ static gint sc_speller_check_word(GeanyDocument *doc, gint line_number, const gc
198
198
}
199
199
200
200
201
+ static gchar * get_chars (ScintillaObject * sci , unsigned int message , gint extra_alloc , gint * out_len )
202
+ {
203
+ gint len = scintilla_send_message (sci , message , 0 , 0 );
204
+ gchar * chars = g_malloc0 (len + 1 + extra_alloc );
205
+
206
+ scintilla_send_message (sci , message , 0 , (sptr_t )chars );
207
+ if (out_len )
208
+ * out_len = len ;
209
+
210
+ return chars ;
211
+ }
212
+
213
+
201
214
gint sc_speller_process_line (GeanyDocument * doc , gint line_number )
202
215
{
203
216
gint pos_start , pos_end ;
204
217
gint wstart , wend ;
205
218
gint suggestions_found = 0 ;
206
219
gint wordchars_len ;
207
220
gchar * wordchars ;
221
+ gchar * whitespaces ;
222
+ gchar * punctuations ;
208
223
gchar * underscore_in_wordchars = NULL ;
209
224
gboolean wordchars_modified = FALSE;
210
225
@@ -216,9 +231,10 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number)
216
231
217
232
/* add ' (single quote) temporarily to wordchars
218
233
* to be able to check for "doesn't", "isn't" and similar */
219
- wordchars_len = scintilla_send_message (doc -> editor -> sci , SCI_GETWORDCHARS , 0 , 0 );
220
- wordchars = g_malloc0 (wordchars_len + 2 ); /* 2 = temporarily added "'" and "\0" */
221
- scintilla_send_message (doc -> editor -> sci , SCI_GETWORDCHARS , 0 , (sptr_t )wordchars );
234
+ /* +1 to allocation to allow for temporarily added "'" */
235
+ wordchars = get_chars (doc -> editor -> sci , SCI_GETWORDCHARS , 1 , & wordchars_len );
236
+ whitespaces = get_chars (doc -> editor -> sci , SCI_GETWHITESPACECHARS , 0 , NULL );
237
+ punctuations = get_chars (doc -> editor -> sci , SCI_GETPUNCTUATIONCHARS , 0 , NULL );
222
238
if (! strchr (wordchars , '\'' ))
223
239
{
224
240
/* temporarily add "'" to the wordchars */
@@ -267,8 +283,12 @@ gint sc_speller_process_line(GeanyDocument *doc, gint line_number)
267
283
/* reset wordchars for the current document */
268
284
wordchars [wordchars_len ] = '\0' ;
269
285
scintilla_send_message (doc -> editor -> sci , SCI_SETWORDCHARS , 0 , (sptr_t )wordchars );
286
+ scintilla_send_message (doc -> editor -> sci , SCI_SETWHITESPACECHARS , 0 , (sptr_t )whitespaces );
287
+ scintilla_send_message (doc -> editor -> sci , SCI_SETPUNCTUATIONCHARS , 0 , (sptr_t )punctuations );
270
288
}
271
289
g_free (wordchars );
290
+ g_free (whitespaces );
291
+ g_free (punctuations );
272
292
return suggestions_found ;
273
293
}
274
294
0 commit comments