<commit_before>﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.ComponentModel.Design;
using Microsoft.Win32;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using System.ComponentModel;
using System.Linq;
using EnvDTE;

namespace Predelnik.RemoveTrailingWhitespaces
{
    [CLSCompliant(false), ComVisible(true)]
    public class OptionsPage : DialogPage
    {
        private bool removeTrailingWhitespacesOnSave = true;
        [Category("All")]
        [DisplayName("Remove Trailing Whitespaces on Save")]
        public bool RemoveTrailingWhitespacesOnSave
        {
            get { return removeTrailingWhitespacesOnSave; }
            set { removeTrailingWhitespacesOnSave = value; }
        }
    };

    internal class RunningDocTableEvents : IVsRunningDocTableEvents3
    {
        RemoveTrailingWhitespacesPackage _pkg;

        public RunningDocTableEvents(RemoveTrailingWhitespacesPackage pkg)
        {
            _pkg = pkg;
        }

        public int OnBeforeSave(uint docCookie)
        {
            if (_pkg.removeOnSave())
            {
                RunningDocumentInfo runningDocumentInfo = _pkg.rdt.GetDocumentInfo(docCookie);
                EnvDTE.Document document = _pkg.dte.Documents.OfType<EnvDTE.Document>().SingleOrDefault(x => x.FullName == runningDocumentInfo.Moniker);<commit_msg>Fix uncaught exception on save all.<commit_after>﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.ComponentModel.Design;
using Microsoft.Win32;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using System.ComponentModel;
using System.Linq;
using EnvDTE;

namespace Predelnik.RemoveTrailingWhitespaces
{
    [CLSCompliant(false), ComVisible(true)]
    public class OptionsPage : DialogPage
    {
        private bool removeTrailingWhitespacesOnSave = true;
        [Category("All")]
        [DisplayName("Remove Trailing Whitespaces on Save")]
        public bool RemoveTrailingWhitespacesOnSave
        {
            get { return removeTrailingWhitespacesOnSave; }
            set { removeTrailingWhitespacesOnSave = value; }
        }
    };

    internal class RunningDocTableEvents : IVsRunningDocTableEvents3
    {
        RemoveTrailingWhitespacesPackage _pkg;

        public RunningDocTableEvents(RemoveTrailingWhitespacesPackage pkg)
        {
            _pkg = pkg;
        }

        public int OnBeforeSave(uint docCookie)
        {
            if (_pkg.removeOnSave())
            {
                RunningDocumentInfo runningDocumentInfo = _pkg.rdt.GetDocumentInfo(docCookie);
                EnvDTE.Document document = _pkg.dte.Documents.OfType<EnvDTE.Document>().SingleOrDefault(x => x.FullName == runningDocumentInfo.Moniker);
                if (document == null)
                    return VSConstants.S_OK;
{'fraction_non_alphanumeric': 0.07652567000322893, 'fraction_numerical': 0.0019373587342589602, 'mean_word_length': 3.175202156334232, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7248144', 'n_tokens_mistral': 848, 'n_tokens_neox': 824, 'n_words': 165}