Bug 574139 - URLHyperlinkDetector: scheme:// is not a hyperlink

Make the behavior more consistent between handling quoted and unquoted
URLs:

  https://

would not give a hyperlink, but

  "https://" or "https:// "

would.

Change the code to not produce hyperlinks for the latter two.

Change-Id: I17f6c16fd96ada810bfc4f635e9d03e8cf5f596b
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/181809
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Mickael Istria <mistria@redhat.com>
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java
index 8e79f41..9de19b4 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java
@@ -418,6 +418,9 @@
 			checkHyperlink(textViewer, 3, "https:// ", "[]");
 			checkHyperlink(textViewer, 3, "https:// foo", "[]");
 			checkHyperlink(textViewer, 3, "https://foo bar", "[https://foo]");
+			checkHyperlink(textViewer, 3, "\"https://\" foo bar", "[]");
+			checkHyperlink(textViewer, 3, "\"https:// \" foo bar", "[]");
+			checkHyperlink(textViewer, 3, "\"https:// foo\" bar", "[]");
 			checkHyperlink(textViewer, 15, "https:// foo https://bar bar", "[https://bar]");
 			checkHyperlink(textViewer, 24, "https:// foo https://bar bar", "[https://bar]");
 			checkHyperlink(textViewer, 15, "<a href=\"test:https://bugs.eclipse.org/bugs\"></a>", "[https://bugs.eclipse.org/bugs]");
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java
index 2ad0898..96bdefe 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -146,6 +146,10 @@
 				urlLength= endOffset - urlOffsetInLine;
 		}
 
+		if (urlOffsetInLine + urlLength == urlSeparatorOffset + 3) {
+			return null; // Only "scheme://"
+		}
+
 		// Set and validate URL string
 		try {
 			urlString= line.substring(urlOffsetInLine, urlOffsetInLine + urlLength);