<commit_before><UserControl x:Class="GitDiffMargin.View.EditorDiffMarginControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:viewModel="clr-namespace:GitDiffMargin.ViewModel"
             xmlns:view="clr-namespace:GitDiffMargin.View"
             xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
             Cursor="Hand"
             ClipToBounds="True"
             d:DataContext="{d:DesignInstance viewModel:EditorDiffMarginViewModel}"
             d:DesignHeight="300"
             d:DesignWidth="9"
             mc:Ignorable="d">
  <UserControl.Resources>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <view:OpaqueColorConverter x:Key="OpaqueColorConverter" />
    <ControlTemplate x:Key="ChangeTemplate" d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
        <Rectangle Width="{Binding Width, Mode=OneWay}" HorizontalAlignment="Left" Margin="{Binding Margin, Mode=OneWay}" Fill="{Binding DiffBrush}" />
    </ControlTemplate>
    <ControlTemplate x:Key="DeletionTemplate" d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
        <Polygon Points="0,0 1,1 0,2 0,0" Fill="{Binding DiffBrush}" Width="9" Height="{Binding Height}" Stretch="Fill" />
    </ControlTemplate>
  </UserControl.Resources>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="9" MinWidth="9" />
    </Grid.ColumnDefinitions>
    <ItemsControl Grid.Column="0"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  ItemsSource="{Binding DiffViewModels, Mode=OneWay}">
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
          <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
      <ItemsControl.ItemContainerStyle>
        <Style TargetType="ContentPresenter" d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
          <Setter Property="VerticalAlignment" Value="Top" />
          <Setter Property="Canvas.Top" Value="{Binding Top, Mode=OneWay}" />
          <Setter Property="Height" Value="{Binding Height, Mode=OneWay}" />
        </Style>
      </ItemsControl.ItemContainerStyle>
      <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Grid Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
                  d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
              <Button Name="diffControl"
                      Tag="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}"
                      Click="Button_Click"
                      MouseDoubleClick="Button_MouseDoubleClick">
                  <Button.Style>
                      <Style TargetType="{x:Type Button}">
                          <Style.Triggers>
                              <DataTrigger Binding="{Binding IsDeletion}" Value="true">
                                  <Setter Property="Template" Value="{StaticResource DeletionTemplate}" />
                              </DataTrigger>
                              <DataTrigger Binding="{Binding IsDeletion}" Value="false">
                                  <Setter Property="Template" Value="{StaticResource ChangeTemplate}" />
                              </DataTrigger>
                          </Style.Triggers>
                      </Style>
                  </Button.Style>
              </Button>
            <Popup AllowsTransparency="True"
                   HorizontalOffset="8"
                   IsOpen="{Binding ShowPopup, Mode=TwoWay}"
                   Placement="Custom"
                   PlacementTarget="{Binding ElementName=diffControl}"
                   CustomPopupPlacementCallback="{x:Static view:EditorDiffMarginControl.CustomPopupPlacementCallback}"
                   StaysOpen="False"
                   Opened="Popup_OnOpened"
                   view:PopupAllowKeyboardInput.IsEnabled="True">
              <Popup.CommandBindings>
                <CommandBinding Command="Close" Executed="Popup_Close" />
              </Popup.CommandBindings>
              <Popup.InputBindings>
                <KeyBinding Key="Escape" Command="Close" />
              </Popup.InputBindings>
              <Border Background="Transparent">
                <StackPanel Orientation="Vertical">
                  <Border HorizontalAlignment="Left"
                          Background="White"
                          BorderBrush="Black"
                          BorderThickness="1,1,1,1">
                    <ContentControl Name="Commands"
                                    Content="{Binding ToolBarTray, Mode=OneWay}"
                                    Focusable="True">
                      <ContentControl.Resources>
                        <Style TargetType="{x:Type imaging:CrispImage}"
                               BasedOn="{StaticResource {x:Type imaging:CrispImage}}">
                          <Setter Property="ScaleFactor" Value="{Binding Path=DataContext.ScaleFactor, ElementName=Commands}" />
                        </Style>
                      </ContentControl.Resources>
                    </ContentControl>
                  </Border>
                 <Border Background="{Binding Background, Mode=OneWay, Converter={StaticResource OpaqueColorConverter}}"
                          BorderBrush="{Binding Foreground, Mode=OneWay}"
                          BorderThickness="1,1,1,1"
                          Margin="0,-1,0,0"
                          Visibility="{Binding IsDiffTextVisible,
                                               Converter={StaticResource BooleanToVisibilityConverter}}">
                    <TextBox Margin="5"
                             SnapsToDevicePixels="True"
                             BorderThickness="0"
                             IsReadOnly="True"
                             FontFamily="{Binding FontFamily, Mode=OneWay}"
                             FontStretch="{Binding FontStretch, Mode=OneWay}"
                             FontStyle="{Binding FontStyle, Mode=OneWay}"
                             FontWeight="{Binding FontWeight, Mode=OneWay}"
                             FontSize="{Binding FontSize, Mode=OneWay}"
                             Text="{Binding DiffText, Mode=OneWay}"
                             Background="{Binding Background, Mode=OneWay, Converter={StaticResource OpaqueColorConverter}}"
                             Foreground="{Binding Foreground, Mode=OneWay}"
                             VerticalScrollBarVisibility="Auto"
                             HorizontalScrollBarVisibility="Auto" /><commit_msg>Improve text rendering<commit_after><UserControl x:Class="GitDiffMargin.View.EditorDiffMarginControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:viewModel="clr-namespace:GitDiffMargin.ViewModel"
             xmlns:view="clr-namespace:GitDiffMargin.View"
             xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
             Cursor="Hand"
             ClipToBounds="True"
             d:DataContext="{d:DesignInstance viewModel:EditorDiffMarginViewModel}"
             d:DesignHeight="300"
             d:DesignWidth="9"
             mc:Ignorable="d">
  <UserControl.Resources>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <view:OpaqueColorConverter x:Key="OpaqueColorConverter" />
    <ControlTemplate x:Key="ChangeTemplate" d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
        <Rectangle Width="{Binding Width, Mode=OneWay}" HorizontalAlignment="Left" Margin="{Binding Margin, Mode=OneWay}" Fill="{Binding DiffBrush}" />
    </ControlTemplate>
    <ControlTemplate x:Key="DeletionTemplate" d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
        <Polygon Points="0,0 1,1 0,2 0,0" Fill="{Binding DiffBrush}" Width="9" Height="{Binding Height}" Stretch="Fill" />
    </ControlTemplate>
  </UserControl.Resources>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="9" MinWidth="9" />
    </Grid.ColumnDefinitions>
    <ItemsControl Grid.Column="0"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  ItemsSource="{Binding DiffViewModels, Mode=OneWay}">
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
          <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
      <ItemsControl.ItemContainerStyle>
        <Style TargetType="ContentPresenter" d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
          <Setter Property="VerticalAlignment" Value="Top" />
          <Setter Property="Canvas.Top" Value="{Binding Top, Mode=OneWay}" />
          <Setter Property="Height" Value="{Binding Height, Mode=OneWay}" />
        </Style>
      </ItemsControl.ItemContainerStyle>
      <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Grid Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
                  d:DataContext="{d:DesignInstance viewModel:EditorDiffViewModel}">
              <Button Name="diffControl"
                      Tag="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}"
                      Click="Button_Click"
                      MouseDoubleClick="Button_MouseDoubleClick">
                  <Button.Style>
                      <Style TargetType="{x:Type Button}">
                          <Style.Triggers>
                              <DataTrigger Binding="{Binding IsDeletion}" Value="true">
                                  <Setter Property="Template" Value="{StaticResource DeletionTemplate}" />
                              </DataTrigger>
                              <DataTrigger Binding="{Binding IsDeletion}" Value="false">
                                  <Setter Property="Template" Value="{StaticResource ChangeTemplate}" />
                              </DataTrigger>
                          </Style.Triggers>
                      </Style>
                  </Button.Style>
              </Button>
            <Popup AllowsTransparency="True"
                   HorizontalOffset="8"
                   IsOpen="{Binding ShowPopup, Mode=TwoWay}"
                   Placement="Custom"
                   PlacementTarget="{Binding ElementName=diffControl}"
                   CustomPopupPlacementCallback="{x:Static view:EditorDiffMarginControl.CustomPopupPlacementCallback}"
                   StaysOpen="False"
                   Opened="Popup_OnOpened"
                   view:PopupAllowKeyboardInput.IsEnabled="True">
              <Popup.CommandBindings>
                <CommandBinding Command="Close" Executed="Popup_Close" />
              </Popup.CommandBindings>
              <Popup.InputBindings>
                <KeyBinding Key="Escape" Command="Close" />
              </Popup.InputBindings>
              <Border Background="Transparent">
                <StackPanel Orientation="Vertical">
                  <Border HorizontalAlignment="Left"
                          Background="White"
                          BorderBrush="Black"
                          BorderThickness="1,1,1,1">
                    <ContentControl Name="Commands"
                                    Content="{Binding ToolBarTray, Mode=OneWay}"
                                    Focusable="True">
                      <ContentControl.Resources>
                        <Style TargetType="{x:Type imaging:CrispImage}"
                               BasedOn="{StaticResource {x:Type imaging:CrispImage}}">
                          <Setter Property="ScaleFactor" Value="{Binding Path=DataContext.ScaleFactor, ElementName=Commands}" />
                        </Style>
                      </ContentControl.Resources>
                    </ContentControl>
                  </Border>
                 <Border Background="{Binding Background, Mode=OneWay, Converter={StaticResource OpaqueColorConverter}}"
                          BorderBrush="{Binding Foreground, Mode=OneWay}"
                          BorderThickness="1,1,1,1"
                          Margin="0,-1,0,0"
                          Visibility="{Binding IsDiffTextVisible,
                                               Converter={StaticResource BooleanToVisibilityConverter}}">
                    <TextBox Margin="5"
                             TextOptions.TextFormattingMode="Ideal"
                             BorderThickness="0"
                             IsReadOnly="True"
                             FontFamily="{Binding FontFamily, Mode=OneWay}"
                             FontStretch="{Binding FontStretch, Mode=OneWay}"
                             FontStyle="{Binding FontStyle, Mode=OneWay}"
                             FontWeight="{Binding FontWeight, Mode=OneWay}"
                             FontSize="{Binding FontSize, Mode=OneWay}"
                             Text="{Binding DiffText, Mode=OneWay}"
                             Background="{Binding Background, Mode=OneWay, Converter={StaticResource OpaqueColorConverter}}"
                             Foreground="{Binding Foreground, Mode=OneWay}"
                             VerticalScrollBarVisibility="Auto"
                             HorizontalScrollBarVisibility="Auto" />
{'fraction_non_alphanumeric': 0.10625930389168498, 'fraction_numerical': 0.006663358616289785, 'mean_word_length': 1.9136720363486164, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6978861', 'n_tokens_mistral': 3554, 'n_tokens_neox': 3228, 'n_words': 486}