diff options
author | Anton Leherbauer | 2010-04-26 12:16:43 +0000 |
---|---|---|
committer | Anton Leherbauer | 2010-04-26 12:16:43 +0000 |
commit | 1244f1fcf364a0ef242557958e51eb36a3b16024 (patch) | |
tree | b5f7074fdb835eb037288231fd98eff6ae672976 | |
parent | 58d2a2e8b608801fc2e565ec1099668d4c4b5ca7 (diff) | |
download | org.eclipse.cdt-1244f1fcf364a0ef242557958e51eb36a3b16024.tar.gz org.eclipse.cdt-1244f1fcf364a0ef242557958e51eb36a3b16024.tar.xz org.eclipse.cdt-1244f1fcf364a0ef242557958e51eb36a3b16024.zip |
Bug 309099 - BadLocationException thrown during code type in a cpp file
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java | 10 | ||||
-rw-r--r-- | core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java index 3bf187f4844..63fe955a505 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BracketInserterTest.java @@ -373,6 +373,16 @@ public class BracketInserterTest extends TestCase { assertSingleLinkedPosition(INCLUDE_OFFSET + 1); } + public void testInsertClosingQuoteInIncludeAtDocumentEnd_Bug309099() throws Exception { + int startOffset = TU_CONTENTS.length(); + setCaret(startOffset); + type("#include "); + type('"'); + assertEquals(startOffset + 11, fDocument.getLength()); + assertEquals("#include \"\"", fDocument.get(startOffset, 11)); + assertSingleLinkedPosition(startOffset + 10); + } + public void testAngleBrackets_165837() throws Exception { setCaret(BODY_OFFSET); type("cout << \n\"aaa\" "); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index e93b299b8cd..5eb432a3dbf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -710,7 +710,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC } private boolean isInsideStringInPreprocessorDirective(ITypedRegion partition, IDocument document, int offset) throws BadLocationException { - if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) { + if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && offset < document.getLength()) { // use temporary document to test whether offset is inside non-default partition String directive = document.get(partition.getOffset(), offset - partition.getOffset() + 1); int hashIdx = directive.indexOf('#'); |