Bug 526793 - The code within @formatter:off block gets formatted when "Duplicate Lines" command is applied
Summary: The code within @formatter:off block gets formatted when "Duplicate Lines" co...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-03 04:43 EDT by Dmitry Katsubo CLA
Modified: 2023-02-12 20:26 EST (History)
2 users (show)

See Also:


Attachments
Java snippet (380 bytes, text/x-java)
2017-11-03 04:43 EDT, Dmitry Katsubo CLA
no flags Details
Initial state (28.03 KB, image/png)
2017-11-03 04:44 EDT, Dmitry Katsubo CLA
no flags Details
Final state after Ctrl-D (51.78 KB, image/png)
2017-11-03 04:44 EDT, Dmitry Katsubo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Katsubo CLA 2017-11-03 04:43:36 EDT
Created attachment 271309 [details]
Java snippet

Initial setup:

* Some code formatting rules, where "Off/On Tags" settings contain the following:
  Off tag: @formatter:off
  On tag: @formatter:on

* Code fragment like in attached example.java.

Steps:

* Select complete Java function (see ).
* Press Ctrl-D ("Duplicate lines")

Actual: Newly inserted lines are formatted not taking into account "@formatter:off" directive.

Expected: As given lines are already formatted according to formatting rules, the lines are duplicated literally.
Comment 1 Dmitry Katsubo CLA 2017-11-03 04:44:10 EDT
Created attachment 271310 [details]
Initial state
Comment 2 Dmitry Katsubo CLA 2017-11-03 04:44:39 EDT
Created attachment 271311 [details]
Final state after Ctrl-D
Comment 3 Mateusz Matela CLA 2017-11-08 16:03:44 EST
Moving to jdt-text.
Core formatter is not invoked in this scenario, there's a separate mechanism for fixing indentation. I'm afraid it could be quite messy making that mechanism respect formatter:off tags.
Comment 4 Dmitry Katsubo CLA 2018-08-28 09:48:50 EDT
Still an issue in Eclipse 4.8.0.v20180611-0656 / JDT 3.14.0.v20180611-0500.
Comment 5 Eclipse Genie CLA 2020-09-09 10:26:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Dmitry Katsubo CLA 2020-09-10 07:02:14 EDT
I have tested the issue on Eclipse v4.14.0.v20191210-0610 (build I20191210-0610) and the issue is still there.
Comment 7 Eclipse Genie CLA 2023-02-08 12:11:26 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Dmitry Katsubo CLA 2023-02-12 20:26:06 EST
I have tested with Eclipse Platform v4.26.0.v20221123-1800 and the issue is there.