Unfortunately [Scintilla](https://www.scintilla.org/index.html), the editing widget Geany uses says this about RTL support "Scintilla provides only limited experimental support on Windows for right-to-left languages like Arabic and Hebrew. While text in these languages may appear correct, interaction with this text may not work correctly as occurs with other editors.".
You don't say what your system is, but it appears to be Linux.
It appears that on Linux using a RTL locale also confuses LTR text near closing brackets. Try with Scite (the reference editor for Scintilla) 5.1.6 should use the same Scintilla as Geany git and if it fails you could report it to Scintilla.
I tested geany from git master on archlinux. This is a new bug on geany git master. It dosn't happen with geany's stable version (1.38).
In fact, it didn't happen to me in the last 10 years using geany in Hebrew.