Fix text preview and some small issues
Hello!
This MR fixes the following issues with the preview text:
- At present, if you copy
1234then the preview text will be1234(Notice the leading space). After this MR is applied it correctly removes the leading space - Currently,
g_strstr_len()is called inefficiently (multiple times with same leading string text). This patch callsg_strstr_len()only on the non-parsed text. - At present, if the copied text is much longer than
preview_lengththeng_strchomp()is called inefficiently. There is no use of chomping that long string. - The present way of chomping also means if you copy
12345678901234567890123456789012345678901234567 90then the preview text is12345678901234567890123456789012345678901234567(notice the trailing whitechar). This MR correctly chomps the whitespace from preview text.
Thanks!