adium 3920:d9c85bd86159: Fix the automatic pasting of URLs from ...
commits at adium.im
commits at adium.im
Fri Jun 3 15:29:35 UTC 2011
details: http://hg.adium.im/adium/rev/d9c85bd86159
revision: 3920:d9c85bd86159
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Fri Jun 03 17:26:55 2011 +0200
Fix the automatic pasting of URLs from the pasteboard when using Edit -> Add Link...
Refs #15229
Subject: adium 3921:20b944ef28e9: Revalidate (and thus determine if "http://" should be prepended) when calling -[SHAutoValidatingTextView setContinuousURLValidationEnabled:TRUE] so it will also revalidate when auto-pasting.
details: http://hg.adium.im/adium/rev/20b944ef28e9
revision: 3921:20b944ef28e9
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Fri Jun 03 17:29:18 2011 +0200
Revalidate (and thus determine if "http://" should be prepended) when calling -[SHAutoValidatingTextView setContinuousURLValidationEnabled:TRUE] so it will also revalidate when auto-pasting.
Fixes #15229
diffs (74 lines):
diff -r 10181f3ca95d -r 20b944ef28e9 Plugins/Link Management/SHAutoValidatingTextView.m
--- a/Plugins/Link Management/SHAutoValidatingTextView.m Fri Jun 03 16:35:19 2011 +0200
+++ b/Plugins/Link Management/SHAutoValidatingTextView.m Fri Jun 03 17:29:18 2011 +0200
@@ -16,6 +16,10 @@
#import "SHAutoValidatingTextView.h"
+ at interface SHAutoValidatingTextView ()
+- (void)revalidate;
+ at end
+
@implementation SHAutoValidatingTextView
- (id)initWithFrame:(NSRect)frameRect
@@ -40,6 +44,10 @@
{
//set the validation BOOL, and immeditely reevaluate view
continuousURLValidation = flag;
+
+ if (continuousURLValidation) {
+ [self revalidate];
+ }
}
- (void)toggleContinuousURLValidationEnabled
@@ -71,15 +79,20 @@
//Catch the notification when the text in the view is edited
- (void)textDidChange:(NSNotification *)notification
{
- if (continuousURLValidation) {//call the URL validatation if set
- NSString *linkURL = [self linkURL];
+ if (continuousURLValidation) {//call the URL validatation if set
+ [self revalidate];
+ }
+}
- URLIsValid = [AHHyperlinkScanner isStringValidURI:linkURL
- usingStrict:YES
- fromIndex:NULL
- withStatus:&validStatus
- schemeLength:NULL];
- }
+- (void)revalidate
+{
+ NSString *linkURL = [self linkURL];
+
+ URLIsValid = [AHHyperlinkScanner isStringValidURI:linkURL
+ usingStrict:YES
+ fromIndex:NULL
+ withStatus:&validStatus
+ schemeLength:NULL];
}
#pragma mark Retrieving URL
diff -r 10181f3ca95d -r 20b944ef28e9 Plugins/Link Management/SHLinkEditorWindowController.m
--- a/Plugins/Link Management/SHLinkEditorWindowController.m Fri Jun 03 16:35:19 2011 +0200
+++ b/Plugins/Link Management/SHLinkEditorWindowController.m Fri Jun 03 17:29:18 2011 +0200
@@ -87,14 +87,14 @@
[label_linkText setLocalizedString:AILocalizedString(@"Link Text:","Label for the text entry area for the name when creating a link")];
[label_URL setLocalizedString:AILocalizedString(@"URL:",nil)];
- if (textView && [[textView textStorage] length] > 0) {
+ if (textView) {
NSRange selectedRange = [textView selectedRange];
NSRange rangeOfLinkAttribute;
NSString *linkText;
id linkURL = nil;
//Get the selected link (We have to be careful when the selection is at the very end of our text view)
- if (selectedRange.location != NSNotFound && NSMaxRange(selectedRange) <= [[textView textStorage] length]) {
+ if ([[textView textStorage] length] > 0 && selectedRange.location != NSNotFound && NSMaxRange(selectedRange) <= [[textView textStorage] length]) {
linkURL = [[textView textStorage] attribute:NSLinkAttributeName
atIndex:selectedRange.location
effectiveRange:&rangeOfLinkAttribute];
More information about the commits
mailing list