<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"

#include "base/string_util.h"
#include "base/sys_string_conversions.h"

@implementation AutocompleteTextFieldEditor

- (void)copy:(id)sender {
  NSPasteboard* pb = [NSPasteboard generalPasteboard];
  [self performCopy:pb];
}

- (void)cut:(id)sender {
  NSPasteboard* pb = [NSPasteboard generalPasteboard];
  [self performCut:pb];
}

- (void)performCopy:(NSPasteboard*)pb {
  [pb declareTypes:[NSArray array] owner:nil];
  [self writeSelectionToPasteboard:pb types:
      [NSArray arrayWithObject:NSStringPboardType]];
}

- (void)performCut:(NSPasteboard*)pb {
  [self performCopy:pb];
  [self delete:nil];
}

- (BOOL)shouldPaste {
  id delegate = [self delegate];
  if (![delegate respondsToSelector:@selector(textShouldPaste:)] ||
      [delegate textShouldPaste:self]) {
    return YES;
  }
  return NO;
}

- (void)paste:(id)sender {
  if ([self shouldPaste]) {
    [super paste:sender];
  }
}

@end<commit_msg>[Mac] Prevent the field from updating the font panel and any ruler state.<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/cocoa/autocomplete_text_field_editor.h"

#include "base/string_util.h"
#include "base/sys_string_conversions.h"

@implementation AutocompleteTextFieldEditor

- (void)copy:(id)sender {
  NSPasteboard* pb = [NSPasteboard generalPasteboard];
  [self performCopy:pb];
}

- (void)cut:(id)sender {
  NSPasteboard* pb = [NSPasteboard generalPasteboard];
  [self performCut:pb];
}

- (void)performCopy:(NSPasteboard*)pb {
  [pb declareTypes:[NSArray array] owner:nil];
  [self writeSelectionToPasteboard:pb types:
      [NSArray arrayWithObject:NSStringPboardType]];
}

- (void)performCut:(NSPasteboard*)pb {
  [self performCopy:pb];
  [self delete:nil];
}

- (BOOL)shouldPaste {
  id delegate = [self delegate];
  if (![delegate respondsToSelector:@selector(textShouldPaste:)] ||
      [delegate textShouldPaste:self]) {
    return YES;
  }
  return NO;
}

- (void)paste:(id)sender {
  if ([self shouldPaste]) {
    [super paste:sender];
  }
}

// We have rich text, but it shouldn't be modified by the user, so
// don't update the font panel.  In theory, -setUsesFontPanel: should
// accomplish this, but that gets called frequently with YES when
// NSTextField and NSTextView synchronize their contents.  That is
// probably unavoidable because in most cases having rich text in the
// field you probably would expect it to update the font panel.
- (void)updateFontPanel {
}

// No ruler bar, so don't update any of that state, either.
- (void)updateRuler {
}

@end
{'fraction_non_alphanumeric': 0.12121212121212122, 'fraction_numerical': 0.0027548209366391185, 'mean_word_length': 4.597302504816955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '132281', 'n_tokens_mistral': 992, 'n_tokens_neox': 942, 'n_words': 260}