diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 2cf064725bd..46b65d15af3 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -1833,12 +1833,8 @@
-
-
-
-
+
+
@@ -1859,12 +1855,8 @@
-
-
-
-
+
+
-
-
+
@@ -1887,6 +1877,7 @@
categoryId="org.eclipse.cdt.ui.templateProposalCategory">
+
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
index 0ee1700ed70..d41a3051b04 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
@@ -17,7 +17,6 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3;
import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jface.text.rules.IPartitionTokenScanner;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -203,7 +202,7 @@ public class CTextTools {
ICPartitions.C_PREPROCESSOR
};
- return new FastPartitioner(getPartitionScanner(), types);
+ return new FastCPartitioner(getPartitionScanner(), types);
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java
new file mode 100644
index 00000000000..8439d665db3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * A slightly adapted FastPartitioner.
+ */
+public class FastCPartitioner extends FastPartitioner {
+
+ /**
+ * Creates a new partitioner for the given content types.
+ *
+ * @param scanner
+ * @param legalContentTypes
+ */
+ public FastCPartitioner(IPartitionTokenScanner scanner, String[] legalContentTypes) {
+ super(scanner, legalContentTypes);
+ }
+
+ public ITypedRegion getPartition(int offset, boolean preferOpenPartitions) {
+ if (preferOpenPartitions && offset == fDocument.getLength() && offset > 0) {
+ ITypedRegion region = super.getPartition(offset - 1, false);
+ try {
+ if (ICPartitions.C_MULTI_LINE_COMMENT.equals(region.getType())) {
+ if (!fDocument.get(offset - 2, 2).equals("*/")) { //$NON-NLS-1$
+ return region;
+ }
+ } else if (ICPartitions.C_SINGLE_LINE_COMMENT.equals(region .getType())) {
+ if (fDocument.getChar(offset - 1) != '\n') {
+ return region;
+ }
+ }
+ } catch (BadLocationException exc) {
+ }
+ }
+ return super.getPartition(offset, preferOpenPartitions);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
index c203cf53ba0..37fa52978d0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
@@ -75,7 +75,7 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
TemplateEngine engine= null;
try {
String partition= TextUtilities.getContentType(viewer.getDocument(), ICPartitions.C_PARTITIONING, offset, true);
- if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT)) {
+ if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
engine= fCommentTemplateEngine;
} else {
if (isValidContext(context)) {