Community
Participate
Working Groups
Hi, when using code formatter or code formatter save participants, cursor position is inaccurate. It's probably because ReplaceEdits are not used everywhere in PDT. Also recent fix for bug 531351 (Code formatter is very slow on big php files - https://git.eclipse.org/r/#/c/117686/) also made it a bit "worse" since we converted multiple ReplaceEdits into a single one, but it improved UI responsiveness a *lot*, and can be reworked in PDT 6.0 or later... Thierry.
I remember that this often appear when comment is reformatted a lot. This is main formatter problem, rather than manipulate ReplaceEdits with whitespaces only (like JDT) it often rewrite entire statement. As the result, for example comment might change it's original position (see bug 439568).
So if we used ReplaceEdits only for whitespaces it would then work much better? Maybe it would be not too hard to modify CodeFormatterVisitor.handleCharsWithoutComments() to create/split ReplaceEdits to contain only minimal non-whitespaces characters differences. But also remember more ReplaceEdits will then trigger my "RewriteSessionEditProcessor.isLargeEdit(multiEdit)" post-formatting hack in PHPCodeFormatter.replaceAll() and will undo correct cursor position ;)