CppTools: Do not indent within string literals

Multi-line strings must be kept as the user wrote them.

Fixes: QTCREATORBUG-20180
Change-Id: I141eff52b55d31215e6f5c6c5a0e026689db877a
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2020-08-13 17:58:40 +02:00
parent d6c3846ab1
commit ddf7f5f232
3 changed files with 19 additions and 5 deletions

View File

@@ -635,7 +635,6 @@ void CodeFormatter::updateStateUntil(const QTextBlock &endBlock)
break;
if (loadLexerState(it) == -1)
break;
previousState = blockData.m_endState;
}
@@ -673,6 +672,16 @@ void CodeFormatter::updateLineStateChange(const QTextBlock &block)
saveBlockData(&next, BlockData());
}
bool CodeFormatter::isInStringLiteral(const QTextBlock &block) const
{
if (!block.previous().isValid())
return false;
BlockData blockData;
if (!loadBlockData(block.previous(), &blockData))
return false;
return !blockData.m_endState.isEmpty() && blockData.m_endState.top().type == string_open;
}
CodeFormatter::State CodeFormatter::state(int belowTop) const
{
if (belowTop < m_currentState.size())