diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java
index a574ce0c5465..528187a0e6b2 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.editorActions.wordSelection;
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase;
import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
@@ -38,7 +39,8 @@ public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBa
@Override
public boolean canSelect(PsiElement e) {
- return e instanceof PsiPlainText || e instanceof PsiComment;
+ return (e instanceof PsiPlainText || e instanceof PsiComment) &&
+ !(e.getContainingFile().getFileType() instanceof CustomSyntaxTableFileType);
}
private static TextRange findParagraphRange(String text, int start, int end) {
diff --git a/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeSelectWordHandler.java b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeSelectWordHandler.java
new file mode 100644
index 000000000000..cc1b3108d4c6
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/ide/highlighter/custom/impl/CustomFileTypeSelectWordHandler.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.highlighter.custom.impl;
+
+import com.intellij.codeInsight.editorActions.BraceMatcherBasedSelectioner;
+import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
+import com.intellij.psi.PsiElement;
+
+/**
+ * @author yole
+ */
+public class CustomFileTypeSelectWordHandler extends BraceMatcherBasedSelectioner {
+ @Override
+ public boolean canSelect(PsiElement e) {
+ return e.getContainingFile().getFileType() instanceof CustomSyntaxTableFileType;
+ }
+}
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index 86e6ab4827c8..45ff088fc711 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -563,6 +563,7 @@
+
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after1.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after1.cs
new file mode 100644
index 000000000000..359af75c3a66
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after1.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after2.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after2.cs
new file mode 100644
index 000000000000..ec957fb8449f
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after2.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after3.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after3.cs
new file mode 100644
index 000000000000..4f6eb2934077
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after3.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after4.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after4.cs
new file mode 100644
index 000000000000..6357e59ac2f6
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after4.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after5.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after5.cs
new file mode 100644
index 000000000000..414d4e118dc4
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after5.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after6.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after6.cs
new file mode 100644
index 000000000000..054e064d4d7b
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after6.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after7.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after7.cs
new file mode 100644
index 000000000000..a1a1e9e3e6e2
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after7.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/after8.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after8.cs
new file mode 100644
index 000000000000..ba5a73382a52
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/after8.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeBraces/before.cs b/platform/platform-tests/testData/selectWord/customFileTypeBraces/before.cs
new file mode 100644
index 000000000000..d45787fe2a02
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeBraces/before.cs
@@ -0,0 +1,3 @@
+if (true) {
+ x = foo[bar(xyzzy + fizzy)];
+}
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/after1.cs b/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/after1.cs
new file mode 100644
index 000000000000..96bd024246d3
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/after1.cs
@@ -0,0 +1 @@
+if (!gets_s(buffer, sizeof(buffer)-1))
\ No newline at end of file
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/after2.cs b/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/after2.cs
new file mode 100644
index 000000000000..5602c0fde01d
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/after2.cs
@@ -0,0 +1 @@
+if (!gets_s(buffer, sizeof(buffer)-1))
\ No newline at end of file
diff --git a/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/before.cs b/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/before.cs
new file mode 100644
index 000000000000..a21f832ccfce
--- /dev/null
+++ b/platform/platform-tests/testData/selectWord/customFileTypeSkipMatchedPair/before.cs
@@ -0,0 +1 @@
+if (!gets_s(buffer, sizeof(buffer)-1))
\ No newline at end of file
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/highlighter/custom/CustomFileTypeWordSelectionTest.java b/platform/platform-tests/testSrc/com/intellij/ide/highlighter/custom/CustomFileTypeWordSelectionTest.java
new file mode 100644
index 000000000000..f34d3576ec36
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/ide/highlighter/custom/CustomFileTypeWordSelectionTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide.highlighter.custom;
+
+import com.intellij.testFramework.PlatformTestCase;
+import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
+import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
+
+/**
+ * @author yole
+ */
+public class CustomFileTypeWordSelectionTest extends LightPlatformCodeInsightFixtureTestCase {
+ public CustomFileTypeWordSelectionTest() {
+ PlatformTestCase.initPlatformLangPrefix();
+ }
+
+ public void testCustomFileTypeBraces() {
+ doTest();
+ }
+
+ public void testCustomFileTypeSkipMatchedPair() {
+ doTest();
+ }
+
+ @Override
+ protected String getBasePath() {
+ return "/platform/platform-tests/testData/selectWord/";
+ }
+
+ private void doTest() {
+ CodeInsightTestUtil.doWordSelectionTestOnDirectory(myFixture, getTestName(true), "cs");
+ }
+}