<commit_before>{CompositeDisposable} = require 'atom'
Tags = require './tags'
TagsListView = require './tags-list-view'

module.exports = IdeHaskellHasktags =
  config:
    hasktagsPath:
      type: "string"
      default: "hasktags.js"
      description: "Path to hasktags executable; if set to 'hasktags.js'
                    (default) will use bundled ghcjs-powered implementation"
    ignoreCloseImplementation:
      type: "boolean"
      default: "true"
      description: "Ignore symbols with the same name that are close together
                    in terms of lines. May require restart."

  showList: (editor, tags) ->
    new TagsListView tags, @tags.inProgress, (tag) =>
      @open(editor, tag)

  open: (editor, tag) ->
    editor ?= atom.workspace.getActiveTextEditor()
    @stack.push
      uri: editor.getURI()
      line: editor.getLastCursor().getBufferRow()
    atom.workspace.open tag.uri,
      initialLine: tag.line
      searchAllPanes: true

  activate: (state) ->
    @stack = []
    @tags = new Tags
    @disposables = new CompositeDisposable
    @disposables.add atom.commands.add 'atom-workspace',
      'ide-haskell-hasktags:show-tags': =>
        return unless @tags?
        @showList null, @tags.listTags()
      'ide-haskell-hasktags:go-back': =>
        if (prevpos = @stack.pop())?
          atom.workspace.open prevpos.uri,
            initialLine: prevpos.line
            searchAllPanes: true
    @disposables.add atom.commands.add 'atom-text-editor',
      'ide-haskell-hasktags:show-file-tags': ({currentTarget}) =>
        return unless @tags?
        @showList currentTarget.getModel(), @tags.listTags(currentTarget.getModel().getURI())
    @disposables.add atom.contextMenu.add
      'atom-text-editor[data-grammar~="haskell"]': [
          label: 'Show File Tags'
          command: 'ide-haskell-hasktags:show-file-tags'
      ]
    @disposables.add atom.menu.add [
        label: 'Haskell IDE'
        submenu: [
          label: 'Hasktags'
          submenu: [
              label: 'Show Tags'
              command: 'ide-haskell-hasktags:show-tags'
            ,
              label: 'Show File Tags'
              command: 'ide-haskell-hasktags:show-file-tags'
          ]
        ]
      ]

  consumeUPI: (service) ->
    upi = service.registerPlugin @upidisp = new CompositeDisposable
    @disposables.add @upidisp

    @upidisp.add atom.commands.add 'atom-text-editor',
      'ide-haskell-hasktags:go-to-declaration': ({currentTarget, detail}) =>
        return unless @tags?
        editor = currentTarget.getModel()
        buffer = editor.getBuffer()
        upi.withEventRange {editor, detail}, ({crange}) =>
          {start, end} = buffer.rangeForRow crange.start.row
          crange2 = {start: crange.start, end: crange.end}
          left = buffer.getTextInRange [start, crange.start]
          crange2.start.column = left.search(/[\w']*$/)
          right = buffer.getTextInRange [crange.end, end]
          crange2.end.column += right.search(/[^\w']/)

          symbol = buffer.getTextInRange crange2
          tags = @tags.findTag(symbol)
          switch tags.length
            when 0 then null
            when 1 then @open editor, tags[0]
            else @showList editor, tags

    @upidisp.add atom.contextMenu.add
      'atom-text-editor[data-grammar~="haskell"]': [
          label: 'Goto Declaration'
          command: 'ide-haskell-hasktags:go-to-declaration'
      ]

    @upidisp

  deactivate: ->
    @disposables.dispose()
    @tags.destroy()
<commit_msg>Go back to the previous column<commit_after>{CompositeDisposable} = require 'atom'
Tags = require './tags'
TagsListView = require './tags-list-view'

module.exports = IdeHaskellHasktags =
  config:
    hasktagsPath:
      type: "string"
      default: "hasktags.js"
      description: "Path to hasktags executable; if set to 'hasktags.js'
                    (default) will use bundled ghcjs-powered implementation"
    ignoreCloseImplementation:
      type: "boolean"
      default: "true"
      description: "Ignore symbols with the same name that are close together
                    in terms of lines. May require restart."

  showList: (editor, tags) ->
    new TagsListView tags, @tags.inProgress, (tag) =>
      @open(editor, tag)

  open: (editor, tag) ->
    editor ?= atom.workspace.getActiveTextEditor()
    @stack.push
      uri: editor.getURI()
      line: editor.getLastCursor().getBufferRow()
      column: editor.getLastCursor().getBufferColumn()
    atom.workspace.open tag.uri,
      initialLine: tag.line
      searchAllPanes: true

  activate: (state) ->
    @stack = []
    @tags = new Tags
    @disposables = new CompositeDisposable
    @disposables.add atom.commands.add 'atom-workspace',
      'ide-haskell-hasktags:show-tags': =>
        return unless @tags?
        @showList null, @tags.listTags()
      'ide-haskell-hasktags:go-back': =>
        if (prevpos = @stack.pop())?
          atom.workspace.open prevpos.uri,
            initialLine: prevpos.line
            initialColumn: prevpos.column
            searchAllPanes: true
    @disposables.add atom.commands.add 'atom-text-editor',
      'ide-haskell-hasktags:show-file-tags': ({currentTarget}) =>
        return unless @tags?
        @showList currentTarget.getModel(), @tags.listTags(currentTarget.getModel().getURI())
    @disposables.add atom.contextMenu.add
      'atom-text-editor[data-grammar~="haskell"]': [
          label: 'Show File Tags'
          command: 'ide-haskell-hasktags:show-file-tags'
      ]
    @disposables.add atom.menu.add [
        label: 'Haskell IDE'
        submenu: [
          label: 'Hasktags'
          submenu: [
              label: 'Show Tags'
              command: 'ide-haskell-hasktags:show-tags'
            ,
              label: 'Show File Tags'
              command: 'ide-haskell-hasktags:show-file-tags'
          ]
        ]
      ]

  consumeUPI: (service) ->
    upi = service.registerPlugin @upidisp = new CompositeDisposable
    @disposables.add @upidisp

    @upidisp.add atom.commands.add 'atom-text-editor',
      'ide-haskell-hasktags:go-to-declaration': ({currentTarget, detail}) =>
        return unless @tags?
        editor = currentTarget.getModel()
        buffer = editor.getBuffer()
        upi.withEventRange {editor, detail}, ({crange}) =>
          {start, end} = buffer.rangeForRow crange.start.row
          crange2 = {start: crange.start, end: crange.end}
          left = buffer.getTextInRange [start, crange.start]
          crange2.start.column = left.search(/[\w']*$/)
          right = buffer.getTextInRange [crange.end, end]
          crange2.end.column += right.search(/[^\w']/)

          symbol = buffer.getTextInRange crange2
          tags = @tags.findTag(symbol)
          switch tags.length
            when 0 then null
            when 1 then @open editor, tags[0]
            else @showList editor, tags

    @upidisp.add atom.contextMenu.add
      'atom-text-editor[data-grammar~="haskell"]': [
          label: 'Goto Declaration'
          command: 'ide-haskell-hasktags:go-to-declaration'
      ]

    @upidisp

  deactivate: ->
    @disposables.dispose()
    @tags.destroy()

{'fraction_non_alphanumeric': 0.12420027816411683, 'fraction_numerical': 0.0019471488178025036, 'mean_word_length': 2.3493246390312064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2466910', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2196, 'n_words': 469}