<commit_before># frozen_string_literal: true

module Textbringer
  class BacktraceMode < Mode
    define_generic_command :jump_to_source_location

    BACKTRACE_MODE_MAP = Keymap.new
    BACKTRACE_MODE_MAP.define_key("\n", :jump_to_source_location_command)

    def initialize(buffer)
      super(buffer)
      buffer.keymap = BACKTRACE_MODE_MAP
    end

    def jump_to_source_location
      file_name, line_number = get_source_location
      find_file(file_name)
      goto_line(line_number)
    end

    private

    def get_source_location
      @buffer.save_excursion do
        @buffer.beginning_of_line
        if @buffer.looking_at?(/^(\S*?):(\d+):/)<commit_msg>Don't jump if filename is not found.<commit_after># frozen_string_literal: true

module Textbringer
  class BacktraceMode < Mode
    define_generic_command :jump_to_source_location

    BACKTRACE_MODE_MAP = Keymap.new
    BACKTRACE_MODE_MAP.define_key("\n", :jump_to_source_location_command)

    def initialize(buffer)
      super(buffer)
      buffer.keymap = BACKTRACE_MODE_MAP
    end

    def jump_to_source_location
      file_name, line_number = get_source_location
      if file_name
        find_file(file_name)
        goto_line(line_number)
      end
    end

    private

    def get_source_location
      @buffer.save_excursion do
        @buffer.beginning_of_line
        if @buffer.looking_at?(/^(\S*?):(\d+):/)
{'fraction_non_alphanumeric': 0.07593123209169055, 'fraction_numerical': 0.0, 'mean_word_length': 3.3793103448275863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4997662', 'n_tokens_mistral': 476, 'n_tokens_neox': 452, 'n_words': 80}