mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-05-16 13:40:18 +00:00
Merge pull request #222 from ZoiteChat/fix-autocorrect-replace
Fix auto-replace to respect whole-word matches
This commit is contained in:
@@ -1,7 +1,19 @@
|
|||||||
if cc.get_id() == 'msvc'
|
if cc.get_id() == 'msvc'
|
||||||
lua_dep = cc.find_library('lua51')
|
lua_dep = cc.find_library('lua51')
|
||||||
else
|
else
|
||||||
lua_dep = dependency(get_option('with-lua'))
|
lua_opt = get_option('with-lua')
|
||||||
|
lua_dep = dependency(lua_opt, required: false)
|
||||||
|
if not lua_dep.found() and lua_opt == 'lua-5.4'
|
||||||
|
foreach lua_name : ['lua5.4', 'lua-5.3', 'lua5.3', 'lua']
|
||||||
|
lua_dep = dependency(lua_name, required: false)
|
||||||
|
if lua_dep.found()
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
endif
|
||||||
|
if not lua_dep.found()
|
||||||
|
error('Dependency "' + lua_opt + '" not found')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
shared_module('lua', 'lua.c',
|
shared_module('lua', 'lua.c',
|
||||||
|
|||||||
@@ -1973,8 +1973,37 @@ replace_handle (GtkWidget *t)
|
|||||||
{
|
{
|
||||||
ptrdiff_t found_offset = found - text;
|
ptrdiff_t found_offset = found - text;
|
||||||
ptrdiff_t found_end_offset = found_offset + (ptrdiff_t) pop_len;
|
ptrdiff_t found_end_offset = found_offset + (ptrdiff_t) pop_len;
|
||||||
|
gboolean start_ok;
|
||||||
|
gboolean end_ok;
|
||||||
int rank;
|
int rank;
|
||||||
ptrdiff_t distance;
|
ptrdiff_t distance;
|
||||||
|
const char *before = found;
|
||||||
|
const char *after = found + pop_len;
|
||||||
|
|
||||||
|
if (before > text)
|
||||||
|
{
|
||||||
|
before = g_utf8_find_prev_char (text, before);
|
||||||
|
start_ok = !before || (!g_unichar_isalnum (g_utf8_get_char (before)) && g_utf8_get_char (before) != '_');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
start_ok = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*after != '\0')
|
||||||
|
{
|
||||||
|
end_ok = !g_unichar_isalnum (g_utf8_get_char (after)) && g_utf8_get_char (after) != '_';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
end_ok = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!start_ok || !end_ok)
|
||||||
|
{
|
||||||
|
found++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (cursor_byte_offset >= found_offset && cursor_byte_offset <= found_end_offset)
|
if (cursor_byte_offset >= found_offset && cursor_byte_offset <= found_end_offset)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user