I am trying to get a conditional to work within a TeXStudio script macro. Specifically, this is what I have:
%SCRIPT
txt = cursor.selectedText()
editor.write("\\left\\langle "+txt+" \\right\\rangle")
cursor.clearSelection()
if (cursor.hasSelection() == false) {
cursor.shift(-14)
}
The above macro, basically wraps the selected text in \left\langle and \right\rangle. The second part is meant to move the cursor inside, if there is no selection. If there is a selection, I want the cursor to be where it would normally be (outside, to the right of \rangle).
The above macro works fine, except it always moves the cursor inside, regardless of whether I have a selection. If I remove the conditional statement, then the macro is always outside. Is this not how conditionals work in TeXStudio?
texfile it will work as you expect. TXS will be able to recognize it and autocomplete it. – Sigur Apr 02 '19 at 01:26cursor.clearSelectionbefore IF has ... – Apr 02 '19 at 23:40