datalad / datalad-gooey

A graphical user interface for DataLad (datalad.org)
https://docs.datalad.org/projects/gooey
Other
4 stars 6 forks source link

Commit message TextEdit field keeps resetting cursor - text goes backwards #303

Closed mslw closed 1 year ago

mslw commented 1 year ago

The cursor in the QTextEdit field for "Description of change" for datalad save jumps to the beginning of the text after every letter, leading to inverted text when trying to write normally:

2022-10-06-131848_586x378_scrot

Technically, this is a cursor jumping, and not the text going right to left. If I insert a letter in the middle of the text, the cursor jumps to the beginning. I only observed this behaviour for this one field.

Steps to reproduce

Select Datalad -> Save the state in a dataset (or the right-click equivalent) and type in the "Description of change" field

Further comments

I tried fixing it, and found it directly related to this piece of code for datalad_gooey.param_widgets.TextParameter (excluding this code stops cursor from moving behavior):

https://github.com/datalad/datalad-gooey/blob/0d202f3fd0889eb70c97f67ec8133fe114470f72/datalad_gooey/param_widgets.py#L221-L222

Other fields based on the QLineEdit widget call the QLineEdit.text() in analogous function.

The QTextEdit does not have .text() method, so QTextEdit.toPlainText() is used instead. However, the docs for toPlainText say:

This property holds the text editor’s contents as plain text..

Previous contents are removed and undo/redo history is reset when the property is set. currentCharFormat() is also reset, unless textCursor() is already at the beginning of the document.

If the text edit has another content type, it will not be replaced by plain text if you call toPlainText(). The only exception to this is the non-break space, nbsp;, that will be converted into standard space.

I tried:

mih commented 1 year ago

Confirmed the issue. Looking into a fix.