koehlma / pygtkspellcheck

A simple but quite powerful spellchecking library for GTK written in pure Python.
GNU General Public License v3.0
23 stars 9 forks source link

Pasted misspelled text merges incorrectly #50

Closed cheywood closed 2 years ago

cheywood commented 2 years ago

Copying and pasting a section of text which includes a misspelled word results in the pasted section being broken up and incorrectly merged with the destination text.

I'll try and explain the behaviour through a set of examples.


Starting with a small example, take a buffer like this

word
 asdfasdf

Cut the asdfasdf (note the preceding space) and paste it before word. This should result in the following buffer

 asdfasdfword

But instead we get

 wordasdfasdf

A slightly longer example, take the following buffer

word
valid asdfasdf valid

Cut valid asdfasdf valid and paste it before word

Expected

valid asdfasdf validword

Result

valid wordasdfasdf valid

I haven't looked into at all yet. Pasting text with misspelled words from elsewhere doesn't appear to trigger the issue.

koehlma commented 2 years ago

I can replicate this problem, however, only with GTK4 but not with GTK3.

Pasting should trigger an insert-text event which will set a mark at the position where the text will be inserted and after the insert rechecks the text starting at that mark (functions _before_text_insert and _after_text_insert). I see no reason why this should interfere with pasting in any way. Maybe this has something to do with copying decorated text?