How to disable automatic script/code formatting?

I have written the following code in a keyword script in Katalon Studio (8.6.0-208):

ResponseObject response = WS.sendRequest(
	findTestObject(
		'API Objects/locationlocking/SetLocationLockStatus', [
			('access_token') : access_token,
			('locationId') : locationId,
			('lockStatus') : lockStatus,
			('lockScope') : lockScope,
			('projectId') : projectId
		]
	)
)

When OPENING the script file the code is changed into the following AND SAVED:

ResponseObject response = WS.sendRequest(
		findTestObject(
		'API Objects/locationlocking/SetLocationLockStatus', [
			('access_token') : access_token,
			('locationId') : locationId,
			('lockStatus') : lockStatus,
			('lockScope') : lockScope,
			('projectId') : projectId
		]
		)
		)

IMHO this is highly undesired automatic behavior (totally messes up change management), which I’ve been trying to fix for a while now. There are some threads covering the same (kind of) issue, but all workarounds offered do not work or are inconclusive or the thread is simply a dead end. So here I am, trying a new round of ‘please help’.

Tried & failed

  • Turning on-off-on/off-on-off to possibly trigger re-setting of property.
  • @formatting:off tag, at least for keywords (Preferences > Java > Code Style > Formatter, edit Active Profile)
  • Disabled options Format Source Code/Correct indentation (Preferences > Java > Code Style > Clean up, edit Active Profile > Code Organizing)
  • Disabled all wrapping Disabled options Format Source Code/Correct indentation (Preferences > Java > Code Style > Formatter, edit Active Profile)
  • Disabled all save actions (Preferences > Java > Editor > Save Actions)
  • Disabled all indentation formatting settings (Preferences > Java > Code Style > Formatter, edit Active Profile > Indentation)

Worth mentioning

  • When applying the Eclipse 2.1 built-in formatting style, the code is formatted to my liking, but still after closing and opening the keyword file, I get the undesired formatting (like above) again!
  • I have verified that the change is made when opening the file, the format remains the same when opening a keyword file in another text editor and is changed when opening (within Katalon Studio)

Eclipse provides the exact feature you want

// @formatting:off
...
// @formatting:on

See How to turn off the Eclipse code formatter for certain sections of Java code? - Stack Overflow

In Katalon Studio’s GUI, Preferences > Java > Code Style > Formatter, edit Active Profile, you can see this option is provided:

I enabled “Off/On tags” and checked if @formatting:off works for a Keyword class in a Katalon Studio project.

Well, curiously enough, the @formatting:off in a Keyword source has no effect. The source is formatted by the Formatter.

I do not see why. I have no idea why Katalon Studio ignores the @formatting:off tag specified. Possibly Katalon developer has never tested this.

2 Likes

Hi @kazurayam

Thank you for your clear reply. I’ve come across the formatting tag and found out too it doesn’t work. I’ll update with an overview of everything that I’ve been tried and did not work.

Kind regards,

Coen

This must be a bug of Katalon Studio.

@vu.tran

1 Like

Tagging some members from the Studio product team here just in case: @Jass @uyen.do :+1:

1 Like

Awesome. I really expect a lot of people will be really happy if this issue could be resolved.

Small experiment, that did not result in stopping autoformatting:

  • Exported profile,
  • Replaced all ‘insert’ to ‘do not insert’ and all ‘true’ to ‘false’.
  • Import & apply profile

Still no effect. :confused: