<commit_before>const vscode = require('vscode'); // eslint-disable-line import/no-unresolved
const df = require('./default-format');

const config = vscode.workspace.getConfiguration('dependency-formatter');

function activate(context) {
  const disposable = vscode.commands.registerCommand('dependency-formatter.formatDependencies', () => {
    try {
      const activeEditor = vscode.window.activeTextEditor;
      activeEditor.edit((editBuilder) => {
        const docText = activeEditor.document.getText();
        const totalLines = activeEditor.document.lineCount;
        const docStart = new vscode.Position(0, 0);
        const docEnd = new vscode.Position(totalLines + 1, 0);
        const fullDocRange = new vscode.Range(docStart, docEnd);
        const updatedDocText = df.defaultFormat(docText);
        if (updatedDocText !== docText) {
          editBuilder.replace(fullDocRange, updatedDocText);
        }
      }).then(() => {
        if (config.get('autosave')) {
          activeEditor.document.save();
        }
      });
    } catch (e) {
      vscode.window.showErrorMessage('Error');
    }
  });

  context.subscriptions.push(disposable);
}
exports.activate = activate;

function deactivate() {
}<commit_msg>Reformat setting object<commit_after>const vscode = require('vscode'); // eslint-disable-line import/no-unresolved
const df = require('./default-format');

const setting = (config =>
  ({
    autosave: config.get('autosave'),
  })
)(vscode.workspace.getConfiguration('dependency-formatter'));

function activate(context) {
  const disposable = vscode.commands.registerCommand('dependency-formatter.formatDependencies', () => {
    try {
      const activeEditor = vscode.window.activeTextEditor;
      activeEditor.edit((editBuilder) => {
        const docText = activeEditor.document.getText();
        const totalLines = activeEditor.document.lineCount;
        const docStart = new vscode.Position(0, 0);
        const docEnd = new vscode.Position(totalLines + 1, 0);
        const fullDocRange = new vscode.Range(docStart, docEnd);
        const updatedDocText = df.defaultFormat(docText);
        if (updatedDocText !== docText) {
          editBuilder.replace(fullDocRange, updatedDocText);
        }
      }).then(() => {
        if (setting.autosave) {
          activeEditor.document.save();
        }
      });
    } catch (e) {
      vscode.window.showErrorMessage('Error');
    }
  });

  context.subscriptions.push(disposable);
}
exports.activate = activate;

function deactivate() {
}
{'fraction_non_alphanumeric': 0.1332542506919731, 'fraction_numerical': 0.0031633056544088573, 'mean_word_length': 3.2736486486486487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '7439698', 'n_tokens_mistral': 743, 'n_tokens_neox': 719, 'n_words': 131}