<commit_before>{CompositeDisposable} = require 'atom'

getEditor = ->
  atom.workspace.getActiveTextEditor()

getView = (model) ->
  atom.views.getView(model)

OverwriteConfig = 'vim-mode-plus-move-selected-text.overwrite'
OverwriteClass = 'vim-mode-plus-move-selected-text-overwrite'

module.exports =
  config:
    overwrite:
      order: 0
      type: 'boolean'
      default: false

  eachEditorElement: (fn) ->
    atom.workspace.getTextEditors().forEach (editor) ->
      fn(getView(editor))

  activate: ->
    @subscriptions = new CompositeDisposable

    @subscribe atom.config.observe OverwriteConfig, (newValue) =>
      @eachEditorElement (editorElement) ->
        editorElement.classList.remove(OverwriteClass)
        editorElement.classList.add(OverwriteClass) if newValue

    @subscribe atom.commands.add 'atom-text-editor',
      'vim-mode-plus-user:toggle-overwrite': ->
        atom.config.set(OverwriteConfig, not atom.config.get(OverwriteConfig))

  deactivate: ->
    @subscriptions?.dispose()
    @subscriptions = {}

    @eachEditorElement (editorElement) ->
      editorElement.classList.remove(OverwriteClass)

  subscribe: (args...) ->
    @subscriptions.add args...

  consumeVim: ->
    for name, klass of require("./move-selected-text")
      @subscribe klass.registerCommand()<commit_msg>:art: cleanup and use native classList.toggle<commit_after>{CompositeDisposable} = require 'atom'

OverwriteConfig = 'vim-mode-plus-move-selected-text.overwrite'
OverwriteClass = 'vim-mode-plus-move-selected-text-overwrite'

module.exports =
  config:
    overwrite:
      order: 0
      type: 'boolean'
      default: false

  eachEditorElement: (fn) ->
    atom.workspace.getTextEditors().forEach (editor) ->
      fn(atom.views.getView(editor))

  activate: ->
    @subscriptions = new CompositeDisposable

    @subscribe atom.config.observe OverwriteConfig, (newValue) =>
      @eachEditorElement (editorElement) ->
        editorElement.classList.toggle(OverwriteClass, newValue)

    @subscribe atom.commands.add 'atom-text-editor',
      'vim-mode-plus-user:toggle-overwrite': ->
        newValue = not atom.config.get(OverwriteConfig)
        atom.config.set(OverwriteConfig, newValue)

  deactivate: ->
    @subscriptions?.dispose()
    @subscriptions = {}

    @eachEditorElement (editorElement) ->
      editorElement.classList.remove(OverwriteClass)

  subscribe: (args...) ->
    @subscriptions.add args...

  consumeVim: ->
    for name, klass of require("./move-selected-text")
      @subscribe klass.registerCommand()
{'fraction_non_alphanumeric': 0.12960062646828505, 'fraction_numerical': 0.0007830853563038371, 'mean_word_length': 3.52212389380531, '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': '5766444', 'n_tokens_mistral': 785, 'n_tokens_neox': 765, 'n_words': 129}