Allows not to cut the file and removes extra logic.
To achieve that do "smart" formatting in one go by adding a trick
with comment to keep the last line break and provide the proper indent
for the current line together with formatting the code above.
Disable adding namespace comments because it causes one extra
formatting pass (not for the manual formatting).
Change-Id: I8f644129606238c5438e636f56e6097ab149aa0c
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
In some cases indenting/formatting after special characters can
break the code. Let's try to avoid such corner cases.
Change-Id: I8918bc460af31d696e49f60e0ea85f34e9ff5664
Fixes: QTCREATORBUG-21474
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
With the extra option "Format while typing" checked try to format
text before the current position without breaking the current input.
To accomplish that we make proper choices which replacements to apply.
The advantage of this change is to decrease the need to manually
format code which is just written.
Some minor bugs are fixed during the testing of this change.
Change-Id: Ibed569042e6c46a881e7a83b1882cf2bb23b3626
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Sometimes it's imnportant where the cursor currently is
to properly format the code without affecting the current line.
Change-Id: I8b1fb11d2303adb5f960c7cb80a0ed2e6e45010f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Ctrl+I with the new check will reformat the selected code or
the current line instead.
Change-Id: Ia5a72c4a09621034d0dfe463f669fe1ca36b0b5f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Adding '.' or ',' very ofter makes the statement invalid.
Do not force the formatting in such cases.
Change-Id: I7e58e5af6eed065a3bc0df29698aececa579feed
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
We do not build texteditor files in unit-tests so some tricks
were required to make ClangFormatIndenter available.
First simple unit-test proofs it builds and runs.
Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>