From 7282721c64a616c99da3a036580075e58d2f3416 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 7 May 2020 13:48:30 +0200 Subject: [PATCH] Fixed prettier cursor placement after style format, and replaced atoi with std::stoi calls --- src/source.cc | 6 +++--- src/tooltips.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/source.cc b/src/source.cc index 0b57c32..560f60a 100644 --- a/src/source.cc +++ b/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()) { } diff --git a/src/tooltips.cc b/src/tooltips.cc index 20e9b26..5bd47bc 100644 --- a/src/tooltips.cc +++ b/src/tooltips.cc @@ -169,8 +169,8 @@ void Tooltip::show(bool disregard_drawn, const std::function &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); }