mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 309099 - BadLocationException thrown during code type in a cpp file
This commit is contained in:
parent
4284816c3b
commit
8b262a1f4d
2 changed files with 11 additions and 1 deletions
|
@ -376,6 +376,16 @@ public class BracketInserterTest extends TestCase {
|
||||||
assertSingleLinkedPosition(INCLUDE_OFFSET + 1);
|
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 {
|
public void testAngleBrackets_165837() throws Exception {
|
||||||
setCaret(BODY_OFFSET);
|
setCaret(BODY_OFFSET);
|
||||||
type("cout << \n\"aaa\" ");
|
type("cout << \n\"aaa\" ");
|
||||||
|
|
|
@ -715,7 +715,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInsideStringInPreprocessorDirective(ITypedRegion partition, IDocument document, int offset) throws BadLocationException {
|
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
|
// use temporary document to test whether offset is inside non-default partition
|
||||||
String directive = document.get(partition.getOffset(), offset - partition.getOffset() + 1);
|
String directive = document.get(partition.getOffset(), offset - partition.getOffset() + 1);
|
||||||
int hashIdx = directive.indexOf('#');
|
int hashIdx = directive.indexOf('#');
|
||||||
|
|
Loading…
Add table
Reference in a new issue