Commit e3f294f5 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Slight improvement to find_close_symbol_forward and find_open_symbol_backward

parent 60e6730b
......@@ -1819,9 +1819,9 @@ bool Source::View::find_close_symbol_forward(Gtk::TextIter iter, Gtk::TextIter &
else {
long curly_count = 0;
do {
if(*iter == positive_char && is_code_iter(iter))
if(curly_count == 0 && *iter == positive_char && is_code_iter(iter))
count++;
else if(*iter == negative_char && is_code_iter(iter)) {
else if(curly_count == 0 && *iter == negative_char && is_code_iter(iter)) {
if(count == 0) {
found_iter = iter;
return true;
......@@ -1859,14 +1859,14 @@ bool Source::View::find_open_symbol_backward(Gtk::TextIter iter, Gtk::TextIter &
else {
long curly_count = 0;
do {
if(*iter == positive_char && is_code_iter(iter)) {
if(curly_count == 0 && *iter == positive_char && is_code_iter(iter)) {
if(count == 0) {
found_iter = iter;
return true;
}
count++;
}
else if(*iter == negative_char && is_code_iter(iter))
else if(curly_count == 0 && *iter == negative_char && is_code_iter(iter))
count--;
else if(*iter == '{' && is_code_iter(iter)) {
if(curly_count == 0)
......
......@@ -2483,6 +2483,34 @@ int main() {
iter.backward_chars(12);
g_assert(buffer->get_insert()->get_iter() == iter);
}
{
buffer->set_text(" test(\n"
" <div onClick={() => {}}>");
auto iter = buffer->end();
buffer->place_cursor(iter);
view.on_key_press_event(&event);
g_assert(buffer->get_text() == " test(\n"
" <div onClick={() => {}}>\n"
" \n"
" </div>");
iter = buffer->end();
iter.backward_chars(11);
g_assert(buffer->get_insert()->get_iter() == iter);
}
{
buffer->set_text(" test(\n"
" <>");
auto iter = buffer->end();
buffer->place_cursor(iter);
view.on_key_press_event(&event);
g_assert(buffer->get_text() == " test(\n"
" <>\n"
" \n"
" </>");
iter = buffer->end();
iter.backward_chars(8);
g_assert(buffer->get_insert()->get_iter() == iter);
}
{
buffer->set_text(" test(\n"
" <div>\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment