Browse Source

Fixed crash if going to a declaration in a changed file that is not saved.

merge-requests/365/head
eidheim 10 years ago
parent
commit
bd61bb032c
  1. 14
      src/window.cc

14
src/window.cc

@ -363,7 +363,18 @@ void Window::create_menu() {
auto location=notebook.get_current_view()->get_declaration_location(); auto location=notebook.get_current_view()->get_declaration_location();
if(location.first.size()>0) { if(location.first.size()>0) {
notebook.open(location.first); notebook.open(location.first);
notebook.get_current_view()->get_buffer()->place_cursor(notebook.get_current_view()->get_buffer()->get_iter_at_line_index(location.second.line-1, location.second.index-1)); auto line=static_cast<int>(location.second.line)-1;
auto index=static_cast<int>(location.second.index)-1;
auto buffer=notebook.get_current_view()->get_buffer();
line=std::min(line, buffer->get_line_count()-1);
if(line>=0) {
auto iter=buffer->get_iter_at_line(line);
while(!iter.ends_line())
iter.forward_char();
auto end_line_index=iter.get_line_index();
index=std::min(index, end_line_index);
buffer->place_cursor(buffer->get_iter_at_line_index(line, index));
while(gtk_events_pending()) while(gtk_events_pending())
gtk_main_iteration(); gtk_main_iteration();
if(notebook.get_current_page()!=-1) if(notebook.get_current_page()!=-1)
@ -371,6 +382,7 @@ void Window::create_menu() {
} }
} }
} }
}
}); });
menu.action_group->add(Gtk::Action::create("SourceGotoMethod", "Go to Method"), Gtk::AccelKey(menu.key_map["source_goto_method"]), [this]() { menu.action_group->add(Gtk::Action::create("SourceGotoMethod", "Go to Method"), Gtk::AccelKey(menu.key_map["source_goto_method"]), [this]() {
if(notebook.get_current_page()!=-1) { if(notebook.get_current_page()!=-1) {

Loading…
Cancel
Save