SubEthaEdit icon indicating copy to clipboard operation
SubEthaEdit copied to clipboard

Search & Replace does not handle \n and \t correctly + is inconsistent. Also rendering problems after Cmd-Z

Open tomm174 opened this issue 6 months ago • 1 comments

Fill the following template, and post it on GitHub Issues or send to [email protected]. Please note that the contents of the sent email can be shared on the Issue page. Please write the contents in English.

Title: Search & Replace incorrctly handles \n & \t + rendering errors after undo


Short Description

Putting \n as the replacement string results in a literal \n in the edited file. similarly \t results in literal \t. Inconsistent results of search & replace seemingly depending on previous contents of 'Replace' box. Also transient incorrect rendering problems Ctrl-Z. If I attempt to replace by pasting a new line character in the replace box, then the search character is replaced by three new lines.

Steps to Reproduce the Issue

Paste some text with a character to be replaced e.g. 79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin)

Position caret to start of line Put , into the 'find' box Put \n into the 'replace' box

TEST 1/ Replace string \n not treated as new line

Click the 'Show the next match' arrow. Click replace, replace, replace.

Expected Result

79(_appserverusr) 80(admin) 81(_appserveradm) 98(_lpadmin)

Actual Result

79(_appserverusr) \n 80(admin) \n 81(_appserveradm) \n 98(_lpadmin)

TEST 2/ Rendering error after Ctrl-Z to undo

Ctrl-Z, Ctrl-Z, Ctrl-Z to undo

Expected Result

79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin)

Actual Result

79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin) \n 80(admin),81(_appserveradm),98(_lpadmin)

  • Then click anywhere and the last 2 lines disappear leaving

79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin)

TEST 3/ Replace all

Steps

setup as for TEST 1 Click 'Replace All'

Expected Result

79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin)

Actual Result

The results are inconsistent, depending - at least partly - on what has been put into the replace box before. I have repeated this and had the , replaced with an actual new-line character, with \n, with three new line characters... Is it that the previous contents of the 'Replace' box are getting appended / prepended to the contents ??? I don't know..

Sorry, I wanted to produce a nice bug report for you but with inconsistent behaviour I really don't know how to. Shame, I quite liked the program but I don't think I can go on using it. Good luck, and thanks for your work.

Some results :

80(admin)

\n 81(_appserveradm)zzz

\n 98(_lpadmin)

79(_appserverusr)\n80(admin)\n81(_appserveradm)\n98(_lpadmin)

79(_appserverusr) 80(admin) 81(_appserveradm) 98(_lpadmin)

(Hooray for the last one)

Environment

  • SubEthaEdit: Version 5.2.4 (9810)
  • System: Version 12.7.4 (Build 21H1123)
  • Language: English
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro11,4
      Processor Name: Quad-Core Intel Core i7
      Processor Speed: 2.5 GHz
      Number of Processors: 1
      Total Number of Cores: 4
      L2 Cache (per Core): 256 KB
      L3 Cache: 6 MB
      Hyper-Threading Technology: Enabled
      Memory: 16 GB
      System Firmware Version: 489.0.0.0.0
      OS Loader Version: 540.120.3~37
      SMC Version (system): 2.29f24
      Serial Number (system): C02TP00MG8WL
      Hardware UUID: BBAC513A-25BB-50A5-90D7-7E773CE32357
      Provisioning UDID: BBAC513A-25BB-50A5-90D7-7E773CE32357


tomm174 avatar Jul 22 '25 14:07 tomm174

The search and replace feature depends on if you use regular expressions on search or not. only if you use regular expressions then we respect the escape characters in the replace box. otherwise the text is litereally replaced (you can put anything in the replace box with copy and paste from any other place). The replace line is essentially a multiline text field (you can resize the whole upper section to show more than one row), so it might be that you have leftover lines from previous situations in there. cmd-a delete should remove all of it. If it contained newlines it is someimes hard to see. And when macos decided to only show scrollbars temporarily this got worse.

Hope this helps, I'm using this feature extensively.

monkeydom avatar Jul 25 '25 06:07 monkeydom