vslavik / poedit

Translations editor for Mac, Windows and Unix
https://poedit.net
MIT License
1.8k stars 279 forks source link

Backspacing a newline should automatically remove the `\n` at the end of the previous line #785

Open ItielMaN opened 1 year ago

ItielMaN commented 1 year ago

STR:

  1. Enter a 2-line translation in a certain PO file
  2. "Regret" your translation of the 2nd line and start backspacing it until you get back to the first line, effectively removing the 2nd line completely

AR: The red \n text is still present at the end of the first line, and you have to backspace twice more to remove the 2 characters.

ER: The \n should probably be automatically removed when the user backspaces the line afterwards.

@vslavik knowing you, I'm guessing this is intentional (probably to make sure the user doesn't accidentally backspace some of their actually-inserted-text?). If that's the case feel free to close this one, even though I'm still not convinced...

vslavik commented 1 year ago

@vslavik knowing you, I'm guessing this is intentional (probably to make sure the user doesn't accidentally backspace some of their actually-inserted-text?)

Not really. It is a consequence of how special characters are present in Poedit - as sequences of normal characters. This is because the native text editing control supports showing non-editable marks (e.g. ¶ for newlines) only on some platforms, so Poedit makes it part of the text.

Related: #604 is a near-duplicate, but using delete instead of backspace.

Over there I thought finding a better way to render all this would be better, but I'm not so sure anymore. There's another similar use case: placeholders, particularly complicated ones (e.g. from XLIFF), where it too would make sense to be able to delete it all at once as a special-purpose "token", and that should then apply to other special sequences like "\n\<newline>" too.