diff --git a/src/project.cc b/src/project.cc
index 91e2939..647ec68 100644
--- a/src/project.cc
+++ b/src/project.cc
@@ -375,6 +375,7 @@ void Project::Clang::debug_backtrace() {
if(backtrace.size()==0)
return;
+ bool cursor_set=false;
for(auto &frame: backtrace) {
std::string row=""+frame.module_filename+"";
@@ -390,6 +391,10 @@ void Project::Clang::debug_backtrace() {
}
(*rows)[row]=frame;
view->selection_dialog->add_row(row);
+ if(!cursor_set && frame.file_path==view->file_path) {
+ view->selection_dialog->set_cursor_at_last_row();
+ cursor_set=true;
+ }
}
view->selection_dialog->on_select=[this, rows](const std::string& selected, bool hide_window) {
diff --git a/src/source_clang.cc b/src/source_clang.cc
index 31b23f0..2482016 100644
--- a/src/source_clang.cc
+++ b/src/source_clang.cc
@@ -1101,7 +1101,7 @@ Source::ClangViewAutocomplete(file_path, language) {
}
line.insert(token_end_pos, "");
line.insert(token_start_pos, "");
- usages.emplace_back(Offset(offset.first.line-1, offset.first.index-1, clang_view->file_path), line);
+ usages.emplace_back(Offset(offset.first.line, offset.first.index, clang_view->file_path), line);
}
}
}
diff --git a/src/window.cc b/src/window.cc
index 3309959..5e027cb 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -507,14 +507,14 @@ void Window::set_menu_actions() {
row=usage.first.file_path.filename().string()+":";
current_page=false;
}
- row+=std::to_string(usage.first.line+1)+": "+usage.second;
+ row+=std::to_string(usage.first.line)+": "+usage.second;
(*rows)[row]=usage.first;
view->selection_dialog->add_row(row);
//Set dialog cursor to the last row if the textview cursor is at the same line
- if(current_page) {
- if(iter.get_line()==static_cast(usage.first.line) && iter.get_line_index()>=static_cast(usage.first.index))
- view->selection_dialog->set_cursor_at_last_row();
+ if(current_page &&
+ iter.get_line()==static_cast(usage.first.line-1) && iter.get_line_index()>=static_cast(usage.first.index-1)) {
+ view->selection_dialog->set_cursor_at_last_row();
}
}
@@ -529,7 +529,7 @@ void Window::set_menu_actions() {
return;
Notebook::get().open(declaration_file);
auto view=Notebook::get().get_current_view();
- view->place_cursor_at_line_index(offset.line, offset.index);
+ view->place_cursor_at_line_index(offset.line-1, offset.index-1);
view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5);
view->hide_tooltips();
};
@@ -544,12 +544,15 @@ void Window::set_menu_actions() {
if(view->get_methods) {
auto methods=Notebook::get().get_current_view()->get_methods();
if(!methods.empty()) {
- auto iter=view->get_iter_for_dialog();
- view->selection_dialog=std::unique_ptr(new SelectionDialog(*view, view->get_buffer()->create_mark(iter), true, true));
+ auto dialog_iter=view->get_iter_for_dialog();
+ view->selection_dialog=std::unique_ptr(new SelectionDialog(*view, view->get_buffer()->create_mark(dialog_iter), true, true));
auto rows=std::make_shared >();
+ auto iter=view->get_buffer()->get_insert()->get_iter();
for(auto &method: methods) {
(*rows)[method.second]=method.first;
view->selection_dialog->add_row(method.second);
+ if(iter.get_line()>=static_cast(method.first.line-1))
+ view->selection_dialog->set_cursor_at_last_row();
}
view->selection_dialog->on_select=[view, rows](const std::string& selected, bool hide_window) {
auto offset=rows->at(selected);