Bug 531456 - improve cursor position after code formatting
Summary: improve cursor position after code formatting
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-21 06:51 EST by Thierry BLIND CLA
Modified: 2020-05-14 10:17 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry BLIND CLA 2018-02-21 06:51:39 EST
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.
Comment 1 Dawid Pakula CLA 2018-02-21 06:59:12 EST
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).
Comment 2 Thierry BLIND CLA 2018-02-21 08:40:52 EST
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 ;)