# My code is lost if after updating in manual mode

**URL:** <https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016>\
**Category:** Bug Report\
**Tags:** bugs-report, katalon-studio\
**Created:** [October 11, 2023, 8:12am UTC](https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016 "2023-10-11T08:12:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![msuryana45](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/msuryana45/32/23870_2.png) [@msuryana45](https://forum.katalon.com/u/msuryana45)\
**Post date:** [October 11, 2023, 8:12am UTC](https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016/1 "2023-10-11T08:12:35Z")

</div>

Hello friends

I experienced something strange while editing the testcase in manual mode. Some actions I updated in manual mode, in the script there is code that I commented first before I updated (manual mode). Once the update is complete, I go back to script mode and the code I commented out disappears. is it like that or is this a Katalon bug?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 11, 2023, 8:18am UTC](https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016/2 "2023-10-11T08:18:43Z")

</div>

You switched Test Case editor from manual mode to script mode, right?

> [@msuryana45](#):
>
> Once the update is complete, I go back to script mode and the code I commented out disappears. is it like that or is this a Katalon bug?

Yes, it is like that.

There are several previous posts about this strangeness. See

> [@Why my commented lines of code are deleted. Didn't knew why it happened ?](http://forum.katalon.com/t/why-my-commented-lines-of-code-are-deleted-didnt-knew-why-it-happened/66421/2):
>
> Once you started writing code in Script mode, you should NEVER switch to Manual mode. When you switch from Manual mode back to Script mode, you will find your code is somewhat changed by KS. Switching between Script mode and Manual mode causes many confusions, which is already known and has been (and will be, I think) left unfixed. [Why do comments always move back to left?](http://forum.katalon.com/t/why-do-comments-always-move-back-to-left/54720/3)[Why is KSE changing scripts and how to avoid it?](http://forum.katalon.com/t/why-is-kse-changing-scripts-and-how-to-avoid-it/65147/2)[ScriptView \> ManualView \> ScriptView](http://forum.katalon.com/t/scriptview-manualview-scriptview/57428) and more

and this

> [@Katalon loses vital code switching to/from Manual View (was Katalon issue Javascript)](http://forum.katalon.com/t/katalon-loses-vital-code-switching-to-from-manual-view-was-katalon-issue-javascript/93332):
>
> In Katalon Studio, when using triple double quotes to define a multi-line string in Groovy, the triple double quotes are automatically replaced by a single double quote, which causes an issue when trying to keep the code as originally written. The problem occurs because Katalon Studio’s Groovy parser interprets triple double quotes as a string literal and converts them to single double quotes, which alters the intended format of the JavaScript code. Is there a way to prevent Katalon Studio fro…

If you want to use the script mode, you should stick to it. You should never switch to the manual mode.

If you want to use the manual mode, you should stick to it. You should never switch to the script mode.

You should not mix the manual mode and the script mode.

Switching from manual mode to script mode, your test case code will be re-generated by Katalon Studio, resulting in something you did not expect to see.

---

<div class="post-metadata">

**Author:** ![msuryana45](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/msuryana45/32/23870_2.png) [@msuryana45](https://forum.katalon.com/u/msuryana45)\
**Post date:** [October 11, 2023, 8:32am UTC](https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016/3 "2023-10-11T08:32:29Z")

</div>

OK, I understand, thanks for the explanation

---

<div class="post-metadata">

**Author:** ![duyluong](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/duyluong/32/1116_2.png) [@duyluong](https://forum.katalon.com/u/duyluong)\
**Post date:** [October 11, 2023, 9:16am UTC](https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016/4 "2023-10-11T09:16:54Z")

</div>

> Switching from manual mode to script mode, your test case code will be re-generated by Katalon Studio, resulting in something you did not expect to see.

FYI: When you add a new step, edit, delete or move test steps in Manual View, Katalon Studio will re-generate your script. If you do nothing in Manual view then switch to Script view, your script will remain the same.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 11, 2023, 12:09pm UTC](https://forum.katalon.com/t/my-code-is-lost-if-after-updating-in-manual-mode/99016/5 "2023-10-11T12:09:53Z")

</div>

I guess, the Manual mode of Test Case editor in Katalon Studio is built on top of the Groovy language’s “[Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) Transformation” feature.

The Manual mode reads the Groovy source of a Test Case to compile it to generate an instance of Abstract Syntax Tree and keep it in memory.

When you modify the test case in the manual mode, the editor transforms the AST instance to store your instructions.

At this stage, the test case editor no longer remembers how the original Groovy source was coded.

When you switch the editor from the manual mode to the script mode, Katalon Studio serializes the AST instance to a Groovy source code. In other words, the test case code is regenerated.

The processing of “from AST to Groovy source serialization” is designed on its own. The serialization processing is not designed to preserve any comments which were originally there in the source. It formats all the String literals as it thinks appropriate. Therefore in the script mode you will find the source which is quite different from what you had previously.

… I guess as such, but I am not sure. I have never seen the source code of the Katalon Studio GUI (an Eclipse-based SWT app) because it is not open sourced. Just I have ever seen a symbol `"AST"` somewhere in a stacktrace message years ago, that is the only reasoning of my guess.

* * *

Once I wrote that I think that Katalon team would NEVER address this _fossil bug_.

> [@Katalon loses vital code switching to/from Manual View (was Katalon issue Javascript)](http://forum.katalon.com/t/katalon-loses-vital-code-switching-to-from-manual-view-was-katalon-issue-javascript/93332/13):
>
> I don’t think that they can implement this.

Still I don’t think they would dare to change the current design of Test Case Editor on top of the “AST” because it is too fundamental to re-invent.
