<commit_before>const {Disposable, Emitter, CompositeDisposable} = require("atom")

const Base = require("./base")
const globalState = require("./global-state")
const settings = require("./settings")
const VimState = require("./vim-state")

module.exports = {
  config: settings.config,

  getStatusBarManager() {
    if (!this.statusBarManager) this.statusBarManager = new (require("./status-bar-manager"))()
    return this.statusBarManager
  },

  getPaneUtils() {
    if (!this.paneUtils) this.paneUtils = new (require("./pane-utils"))()
    return this.paneUtils
  },

  activate() {
    this.emitter = new Emitter()
    settings.notifyDeprecatedParams()

    if (atom.inSpecMode()) settings.set("strictAssertion", true)

    this.subscriptions = new CompositeDisposable(
      ...Base.init(this.getEditorState),
      ...this.registerCommands(),
      this.registerVimStateCommands(),
      this.observeAndWarnVimMode(),
      atom.workspace.observeTextEditors(editor => {
        if (!editor.isMini()) {
          this.emitter.emit("did-add-vim-state", new VimState(editor, this.getStatusBarManager(), globalState))
        }
      }),
      atom.workspace.onDidChangeActivePaneItem(() => {
        this.demaximizePane()
        if (settings.get("automaticallyEscapeInsertModeOnActivePaneItemChange")) {
          VimState.forEach(vimState => {
            if (vimState.mode === "insert") vimState.activate("normal")
          })
        }
      }),
      atom.workspace.onDidStopChangingActivePaneItem(item => {
        if (!atom.workspace.isTextEditor(item)) {
          if (this.statusBarManager) this.statusBarManager.clear()
          return
        }
        if (item.isMini()) return

        VimState.forEach(vimState => vimState.clearFlash())

        // Still there is possibility editor is destroyed and don't have corresponding
        // vimState #196.
        const vimState = this.getEditorState(item)
        if (!vimState) return

        vimState.updateStatusBar()
        if (globalState.get("highlightSearchPattern") || vimState.__highlightSearch) {
          vimState.highlightSearch.refresh()
        }
      }),
      // Refresh highlight based on globalState.highlightSearchPattern changes.
      // -------------------------
      globalState.onDidChange(({name, newValue}) => {
        if (name !== "highlightSearchPattern") return
        if (newValue) {
          VimState.forEach(vimState => vimState.highlightSearch.refresh())
        } else {
          VimState.forEach(vimState => {
            // avoid populate prop unnecessarily on vimState.reset on startup
            if (vimState.__highlightSearch) vimState.highlightSearch.clearMarkers()<commit_msg>:memo: for workaround reason<commit_after>const {Disposable, Emitter, CompositeDisposable} = require("atom")

const Base = require("./base")
const globalState = require("./global-state")
const settings = require("./settings")
const VimState = require("./vim-state")

module.exports = {
  config: settings.config,

  getStatusBarManager() {
    if (!this.statusBarManager) this.statusBarManager = new (require("./status-bar-manager"))()
    return this.statusBarManager
  },

  getPaneUtils() {
    if (!this.paneUtils) this.paneUtils = new (require("./pane-utils"))()
    return this.paneUtils
  },

  activate() {
    this.emitter = new Emitter()
    settings.notifyDeprecatedParams()

    if (atom.inSpecMode()) settings.set("strictAssertion", true)

    this.subscriptions = new CompositeDisposable(
      ...Base.init(this.getEditorState),
      ...this.registerCommands(),
      this.registerVimStateCommands(),
      this.observeAndWarnVimMode(),
      atom.workspace.observeTextEditors(editor => {
        if (!editor.isMini()) {
          this.emitter.emit("did-add-vim-state", new VimState(editor, this.getStatusBarManager(), globalState))
        }
      }),
      atom.workspace.onDidChangeActivePaneItem(() => {
        this.demaximizePane()
        if (settings.get("automaticallyEscapeInsertModeOnActivePaneItemChange")) {
          VimState.forEach(vimState => {
            if (vimState.mode === "insert") vimState.activate("normal")
          })
        }
      }),
      atom.workspace.onDidStopChangingActivePaneItem(item => {
        if (!atom.workspace.isTextEditor(item)) {
          if (this.statusBarManager) this.statusBarManager.clear()
          return
        }
        if (item.isMini()) return

        // [FIXME] Clear existing flash markers for all vimState to avoid hide/show editor re-start flash animation.
        // This is workaround for "the keyframe animation being restarted on re-activating editor"-issue.
        // Ideally I want to remove this and keyframe animation state is mainained across hide/show editor item.
        VimState.forEach(vimState => vimState.clearFlash())

        // Still there is possibility editor is destroyed and don't have corresponding
        // vimState #196.
        const vimState = this.getEditorState(item)
        if (!vimState) return

        vimState.updateStatusBar()
        if (globalState.get("highlightSearchPattern") || vimState.__highlightSearch) {
          vimState.highlightSearch.refresh()
        }
      }),
      // Refresh highlight based on globalState.highlightSearchPattern changes.
      // -------------------------
      globalState.onDidChange(({name, newValue}) => {
        if (name !== "highlightSearchPattern") return
        if (newValue) {
          VimState.forEach(vimState => vimState.highlightSearch.refresh())
        } else {
          VimState.forEach(vimState => {
            // avoid populate prop unnecessarily on vimState.reset on startup
            if (vimState.__highlightSearch) vimState.highlightSearch.clearMarkers()
{'fraction_non_alphanumeric': 0.13138177382819308, 'fraction_numerical': 0.0010454783063251437, 'mean_word_length': 2.8164893617021276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '1006331', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1569, 'n_words': 313}