Disable Scripting Auto-Complete

I have gotten very used to a specific process while I'm writing Python code. Namely, anytime I use characters that are used in pairs I'll just quickly add them both first and then add the content between then (i.e. { }, ( ), " ", ' ', etc.).

Recently there's been an update where I've noticed that the script will auto-complete these special characters and add the closing character for you, so often times I'll end up with {}} instead of {}.

There was also a feature added to auto-wrap strings in quotes if you highlight the string and press quote. This can be annoying at times as well.

Is there a way to disable this behavior?

1 Like

Basically no, although I'm sure @justinedwards.jle can cook something up.

To give a starting point, you'll need to find every com.inductiveautomation.ignition.designer.gui.tools.PythonTextArea,
call its' getTextArea() method to retrieve the inner RSyntaxTextArea, then setInsertPairedCharacters(false).

You might be able to do something fun with com.inductiveautomation.ignition.designer.gui.tools.PythonTextArea.Companion.INSTANCE, which should (somewhere in memory internally) have a list of open PythonTextArea instances, but it won't be super easy to get at.

In some future release I could add the ability to toggle this behavior to the right click 'options' menu you get, but it won't be for some time, and it's pretty low priority (unless more people are annoyed by it and just haven't said anything).

2 Likes

I find it mildly annoying. FWIW.

1 Like

I haven't experienced it as it must not be in the version I am using. I tend to do the same thing as @amarks, and would find it annoying until I just decided to get used to it.

It's kind of the default for any programming-oriented editor/IDE.

vscode2

When I'm using a function like system.gui.color, I often ignore the auto complete and type my numbers in directly, so I end up with something like this: system.gui.color(240, 240, 0 green, blue, alpha). Then, on the last character, I'll intuitively press shift + end to highlight the unwanted text red, green, blue) expecting it to vanish when I type the last character ).

...but the unwanted text doesn't vanish. Instead, the closing parenthesis is not administered, and my cursor is simply kicked down to the next row leaving all of the unwanted text unaltered.

The other Ignition auto-complete related thing that trips up my flow are floats. I'll be typing a float and, when I hit the decimal key, the auto complete pops up and sometimes gets in the way.

I imagine these occurrences are the natural result of switching back and forth between development software. Similar things happen to me when I switch OS environments. For example, keyboard shortcuts sometimes don't do what I want them to do because I've somehow mixed up the cmd and ctrl keys :rage: :rofl: :rofl:.

I couldn't find that attribute, but I was able to disable the autocomplete for any open script editor by running this script in the script console:

def getAllComponentsOfClass(container, className):
	foundComponents = []
	for component in container.components:
		if component.__class__.__name__ == className:
			foundComponents.append(component)
		else:
			foundComponents.extend(getAllComponentsOfClass(component, className))
	return foundComponents

from java.awt import Window
for window in Window.getWindows():
	scriptEditors = getAllComponentsOfClass(window, 'PythonTextArea$textArea$1')
	for editor in scriptEditors:
		for listener in editor.document.documentListeners:
			if listener.__class__.__name__ == 'AutoCompletion$AutoActivationListener':
				editor.document.removeDocumentListener(listener)

It simply removes the listener responsible for auto completion from all of the open script editors.

Edit: See update in this post

1 Like

You can just toggle parameter assistance off?

If you do that once, it'll take effect on all open script editors and any new ones for the duration of that designer instance. Not as good as a persistent setting, but a lot easier to do :person_shrugging:

This one we're tracking as a bug, just low impact enough it hasn't gotten prioritized :frowning_face:

for window in Window.getWindows():
	ptas = getAllComponentsOfClass(window, 'PythonTextArea')
	for pta in ptas:
		pta.textArea.insertPairedCharacters = False

As a total aside, I'd recommend making your getAllComponentsOfClass function a generator, so you're not needlessly building up lists (unless you want to be) when doing these traversal operations:

def getAllComponentsOfClass(container, className):
	for component in container.components:
		if component.__class__.__name__ == className:
			yield component
		else:
			for c in getAllComponentsOfClass(component, className):
				yield c
2 Likes

This is not something I would do. Overall, I actually like the auto complete, and I hope it gets developed further. Sometimes my flow gets tripped up when some little unexpected thing happens, but I was only contemplating it in this context because I was pinged in this post. As far as nuisances go, Ignition's auto complete is hardly a blip on my radar.

In any case, if somebody wanted to override some aspect of the auto complete behavior, or create their own, I imagine wrapping or replacing that document listener would be the simplest approach.

[quote="PGriffith, post:8, topic:98898"]

for window in Window.getWindows():
	ptas = getAllComponentsOfClass(window, 'PythonTextArea')
	for pta in ptas:
		pta.textArea.insertPairedCharacters

[/quote]

I actually did this per your instruction originally, and I couldn't find the attribute. The pta.textarea call doesn't retrieve a pure RSyntaxTextArea. It gets a PythonTextArea$textArea$1'. However, even when I approached it reflectively to get at the raw class, .gerClass().getSuperclass().getSuperclass(), in this case, I didn't see that attribute on the RSyntaxTextArea.

Update: After updating my test gateway to 8.1.44, I noticed an extra ' get added whenever I would create a comment block using '''. I hadn't seen that behavior before, and I remembered this post. Running the test again, the attribute is there, so the fact that I couldn't find it was because I wasn't using the latest version.

Here is an updated version of the script based on the feedback above:

from java.awt import Window
def getAllComponentsOfClass(container, className):
	for component in container.components:
		if component.__class__.__name__ == className:
			yield component
		else:
			for c in getAllComponentsOfClass(component, className):
				yield c

for window in Window.getWindows():
	if window.visible:
		scriptEditors = getAllComponentsOfClass(window, 'PythonTextArea$textArea$1')
#		Use this for Perspective's advanced style sheet:
#		scriptEditors = getAllComponentsOfClass(window, 'RSyntaxTextArea') 
		for editor in scriptEditors:
			editor.insertPairedCharacters = False

I've tested it and it works

One interesting observation I made while subsequently testing was in the Perspective style sheet—which is the only pure RSyntaxTextArea I'm aware of in Ignition. It does auto complete the ' on the first press, but it deletes the auto completion if the apostrophe is pressed a second time, and the quadruple apostrophe doesn't occur, so perhaps the key to fixing the PythonTextArea$textArea$1 nuisance duplications is in the style sheet's implementation.