Formatting package in editor moves the cursor.

I’m using Toad for Oracle version 12.5.1.1.

I have this strange problem when I format code (using the shortcut but even when using the Menu), the cursor position jumps.

It moves ahead a random number of lines.

For e.g I was in line 1208 when I formatted, now the cursor moved to line 1521.

It is really annoying as it breaks your concentration as now you have to move back to the previous place you were working on.

Is there any way to fix this?

Thank You!

Arijit

When the caret moves does it remain at the same point in your code where it was positioned before? The expected behavior is for the caret to remain at the same logical point in your code. For example, if the caret was on a variable assignment prior to formatting then it should remain on that assignment following formatting, even if that code is now many lines different than before. If this is not what you’re seeing can you provide a code sample to reproduce? I tried a 1500 line package in Toad 12.5 positioning the caret at various places and formatting. The caret moved, but remained at the same logical position.

Michael

Unfortunately the caret does not stay at the logical location.

In fact in my case it jumps over to the next function in the package. I’m now seeing this behavior even when I paste code.

For e.g. when I paste code into my existing package, I expect the caret to go to the end of the block that was pasted in.

But the caret moved to a point two lines after the line where the pasted block ended.

I’m trying to figure out how to post an example without posting actual code I’m writing.

Is there any other way I can demonstrate the problem?

Thank You!

Arijit

Can you reproduce it with a sample package or any of the code in the Oracle supplied .SQL files in your client’s .\RDBMS\ADMIN folder?

Hi Michael,

Thank you for helping out :slight_smile:

I've used the 'hubproc.pkb' package file from the \RDBMS\ADMIN folder to demonstrate the issue here.

There are two screenshots that describe the problem. In the first one you can see that the caret is right next to the IF on line 50.

Now when I hit format (Ctrl + Shift + f), the formatter runs and after its finished the caret ends up next to the WHERE on line 54. This is shown in the second screenshot

Now in this case the jump is not so 'severe' so to speak as I'm still in the same part of the file and the window didn't scroll at all. The caret only jumped 4 lines.

But when I'm formatting the package that I'm working on, the jump is more than 300 lines. The window scrolls a lot and throws me off. I have to now figure out where the caret landed and then get back to the part I was editing.

But I've noticed that the jump is consistent. What I mean is from a particular caret position if the jump is X places, it always jumps X places from the position.

Hope this helps. I can try to record my screen to show the issue but that would take time as I don't have any recording software available with me and I have to check with my organisation's IT which software I can use.

Thank You!

Arijit

Trying to follow. You are using 12.5.1, from July 2014 if google is right. And you ran into that issue only now? Using 12.10 I could not reproduce it neither.
Andre

Hi Andre,

Well I got 12.5 installed this year. And it was working fine till now. Recently I faced a weird issue with Toad.

It wouldn’t show me data in one schema only. All other schemas worked fine. Also Toad stopped showing me the ‘Statement processing…’ popup and had generally become slow.

This happened all of a sudden with no indication of what caused it.

So I ‘reset’ Toad by removing all the .INI files from the User Files folder except the CONNECTIONS.INI file. After that I copied a specific fmtPlus.opt file (that is recommended to be used by us for formatting our files) to the User Files folder.

I’m facing the problem since then.

Although I can imagine that I might have messed with some formatter setting while the reset, I cannot imagine why the caret would jump after formatting.

Thank You!

Arijit

Any update anyone?

I don’t have hubproc.pkb in any of my client installations, but I tried with a couple of others of varying size using both the “split file” option and not. In every case my caret remained at the correct location. I tested in 12.10. If you want to zip and email me your user files folder I can run it through 12.5 to try and reproduce and then see if the problem exists in 12.10 using the same options. michaelstaszewskiquest.com

Hi Michael,

Thank you for your help!

I’m not sure if I’ll be able to send the entire contents of the User Files directory as that contains some company specific information and I’m not at liberty to share that.

However would it help if you tell me specifically which files/folders from the User Files folder to share? I could do that.

Also I could share the entire folder if I knew where user specific information such as connection data, usernames etc are located. I could remove them and send you the rest.

Would that help?

Regards,

Arijit

Without knowing where the problem lies all of the files excluding Conneciton*.ini would be preferable., but if you want to start smaller I’d say sending Toad.ini, FmtPlus.opt, and LexLib.lxl would be a good place to start.

Thank you for your help!

I have mailed you the files.

Regards,

Arijit Kanrar

I’ve logged this for the formatter. When using Tabs instead of Spaces for indenting the post-formatting offset returned for the pre-formatted caret position is incorrect. It appears to assume that spaces are used for formatting.

There’s no way to retroactively fix your version of Toad and the only workaround is to change your formatter options to use Space instead of Tab. On the Formatter page in Options the setting is under the Spacing|Tabs node.

I also see that you have mixed tab settings. You have the Formatter configured to use Tabs, but the Editor is set to use Spaces (on the Editor|Behavior page in Options). Ideally you should have the settings matched. Toad 12.10 removes the Tab settings in Formatter options and your Editor tab settings are used so it’s less confusing.

Michael

Wow that fixed it!

Thank you Michael. You were great help!

So now here is what I understand. The code in Toad that determines where the caret has to be after formatting always assumes that spaces are used for formatting and does not know that the formatter is actually using tabs instead.

So now the caret position gets out of whack because the offset is computed “with a wrong unit” so to speak.

Correct? Well who would’ve thought of that?

Also I assume that the formatter is not present as a DLL or something that can be swapped with a newer version right? Because you said that it cannot be fixed in this version of Toad.

Anyway its moot now because the problem is solved.

Thank you for your immense help again Michael. You have saved me hours of frustration.

Is there a way in Toadworld to mark your answer as the correct answer?

Regards,

Arijit

“The code…that determines where the caret has to be after formatting always assumes that spaces are used”

That’s what it seems like. In tests the difference in position from actual caret position to the expected location is exactly the number of characters that would be different in the source had spaces been used instead of tab up to that point.

“Is there a way in Toadworld to mark your answer as the correct answer?”

This thread was started as a discussion instead of a question. Discussions can’t have replies marked as answers. I’ve changed the thread to be a question so you can now mark any reply as an answer.

Michael

Right I get it now.

You said you have logged this on the issue tracker. Is that out in public or is it internal to Quest Software?

If it’s public is there a link we can check to see updates?

Regards,

Arijit Kanrar

It is not public.