mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Auto-insert semicolon after array or struct initializer
This commit is contained in:
parent
f6ab39e0ce
commit
b9d5827fc8
3 changed files with 8 additions and 3 deletions
|
@ -503,6 +503,10 @@ public class CAutoIndentTest extends TestCase {
|
|||
tester.reset();
|
||||
tester.type("for (;;) /*class*/ {\n"); //$NON-NLS-1$
|
||||
assertEquals("for (;;) /*class*/ {\n\t\r\n}", tester.fDoc.get()); //$NON-NLS-1$
|
||||
|
||||
tester.reset();
|
||||
tester.type("int i[5]={\n"); //$NON-NLS-1$
|
||||
assertEquals("int i[5]={\n\t\t\r\n};", tester.fDoc.get()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testSmartPasteWhitesmiths_Bug180531() throws Exception {
|
||||
|
|
|
@ -260,7 +260,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
int p = (c.offset == docLength ? c.offset - 1 : c.offset);
|
||||
|
||||
CIndenter indenter = new CIndenter(d, scanner, fProject);
|
||||
StringBuffer indent = indenter.computeIndentation(p);
|
||||
StringBuffer indent = indenter.computeIndentation(c.offset);
|
||||
if (indent == null)
|
||||
indent = new StringBuffer();
|
||||
if (addIndent > 0 && indent.length() == 0) {
|
||||
|
@ -306,7 +306,8 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
|
|||
int bound= c.offset > 200 ? c.offset - 200 : CHeuristicScanner.UNBOUND;
|
||||
int bracePos = scanner.findOpeningPeer(c.offset - 1, bound, '{', '}');
|
||||
if (bracePos != CHeuristicScanner.NOT_FOUND) {
|
||||
if (scanner.looksLikeCompositeTypeDefinitionBackward(bracePos, bound)) {
|
||||
if (scanner.looksLikeCompositeTypeDefinitionBackward(bracePos, bound) ||
|
||||
scanner.previousToken(bracePos - 1, bound) == Symbols.TokenEQUAL) {
|
||||
buf.append(';');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -908,7 +908,7 @@ public final class CIndenter {
|
|||
case Symbols.TokenLPAREN:
|
||||
case Symbols.TokenLBRACE:
|
||||
case Symbols.TokenLBRACKET:
|
||||
return handleScopeIntroduction(offset + 1);
|
||||
return handleScopeIntroduction(Math.min(offset + 1, fDocument.getLength()));
|
||||
|
||||
case Symbols.TokenEOF:
|
||||
// trap when hitting start of document
|
||||
|
|
Loading…
Add table
Reference in a new issue