Browse Source

Fixed prettier cursor placement after style format, and replaced atoi with std::stoi calls

pipelines/235045657
eidheim 6 years ago
parent
commit
7282721c64
  1. 6
      src/source.cc
  2. 4
      src/tooltips.cc

6
src/source.cc

@ -681,7 +681,7 @@ void Source::View::setup_format_style(bool is_generic_view) {
}
}
command += " --stdin-filepath " + filesystem::escape_argument(this->file_path.string()) + " --print-width 120 --config-precedence prefer-file";
command += " --stdin-filepath " + filesystem::escape_argument(this->file_path.string());
if(get_buffer()->get_has_selection()) { // Cannot be used together with --cursor-offset
Gtk::TextIter start, end;
@ -704,7 +704,7 @@ void Source::View::setup_format_style(bool is_generic_view) {
std::getline(stderr_stream, line);
if(!line.empty() && line != "NaN") {
try {
auto offset = atoi(line.c_str());
auto offset = std::stoi(line);
if(offset < get_buffer()->size()) {
get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(offset));
hide_tooltips();
@ -721,7 +721,7 @@ void Source::View::setup_format_style(bool is_generic_view) {
std::smatch sm;
if(std::regex_match(line, sm, regex)) {
try {
auto start = get_iter_at_line_offset(atoi(sm[2].str().c_str()) - 1, atoi(sm[3].str().c_str()) - 1);
auto start = get_iter_at_line_offset(std::stoi(sm[2].str()) - 1, std::stoi(sm[3].str()) - 1);
++num_errors;
while(start.ends_line() && start.backward_char()) {
}

4
src/tooltips.cc

@ -169,8 +169,8 @@ void Tooltip::show(bool disregard_drawn, const std::function<void()> &on_motion)
Notebook::get().open(path);
if(auto view = Notebook::get().get_current_view()) {
try {
auto line = atoi(sm[2].str().c_str()) - 1;
auto offset = atoi(sm[3].str().c_str()) - 1;
auto line = std::stoi(sm[2].str()) - 1;
auto offset = std::stoi(sm[3].str()) - 1;
view->place_cursor_at_line_offset(line, offset);
view->scroll_to_cursor_delayed(true, false);
}

Loading…
Cancel
Save