Skip to main content

Bug fixes around undo/redo and copy/paste

I found a report of a case recently where Regex Hero would sporadically cause Chrome to crash. It was in a comment on StackOverflow, and I'm lucky to have found it. I didn't have much to go on, but I take reports like this seriously.

First of all, I had never seen this actually happen before. But I began by banging on things trying to make anything and everything break that I possibly could. My method is perhaps a bit crude and it simply takes time and some knowledge of what's going on in the code to get anywhere.

Here's what I managed to fix, in order of discovery:
  1. There was a layout problem involving the minimum vertical height of Regex Hero. After you shrink the window beyond a certain point a scroll bar appears so as not to fold the UI on top of itself. Well there was a logic problem in this calculation which could actually throw an error in certain circumstances. The error was being trapped though, and couldn't have caused the crash.
  2. The expand/collapse options button along the right hand side of the app had an unusual bug where, after clicking, the tooltip would be reused for other UI elements. I fixed it by using just one button rather than hiding/showing two different ones. Again, this was a weird bug but not one that could've caused the crash.
  3. Whenever you right click text and choose Cut/Copy/Paste, Regex Hero accesses the clipboard programmatically. On first use, this will throw a security warning from Silverlight (there's no way around that). The trouble is that if you choose not to allow Regex Hero access to the clipboard, Regex Hero would kind of fall on its face and not handle that condition gracefully. Again, an exception would be thrown, but it was caught and couldn't have caused anything to crash. I improved this process a bit and I now provide a follow up dialog.
  4. I took a couple days and came back to this. And just yesterday I finally reproduced the problem. The problem, it turns out, comes from another bug in the RichTextBox. And it's not isolated to Chrome. The same behavior occurs in IE9. Regex Hero was programmatically replacing line feeds with carriage returns when loading your previously stored text from isolated storage. I do this to ensure consistent behavior within the app. A separate string variable assigned to the text value of each textbox is then reshaped as necessary depending on if you have the CrLf option checked within Regex Hero. However, if you have more than 10 lines of text, then cut the top 9, then hit undo, the built-in undo functionality fails. The RichTextBox undo system seems to have a serious problem with carriage returns. It can't seem to fully restore from its history, only actually rendering 3 lines of text. The rendering pipeline then seems to be out of sync with what the text value actually equals. It's odd. And it causes Silverlight to freeze, sometimes bringing the whole browser down. I'm reporting this to Microsoft. My solution is to now replace all carriage returns with line feeds instead. Behind the scenes we have the same effect and the app works as it should, but it effectively avoids this bug.


Popular posts from this blog

Regex Hero for Windows 10 is Underway

Awhile back I began working on an HTML5 / JavaScript version of Regex Hero . However, it was a huge undertaking essentially requiring a complete rewrite of the entire application. I have not had enough time to dedicate to this lately. So I've begun again, this time rewriting Regex Hero to work in WPF. It'll be usable in Windows 10 and downloadable from the Microsoft Store. This is a much easier task that also has the advantage of running the .NET regex library from the application itself. This will allow for the same speedy experience of testing your regular expressions and getting instant feedback that Regex Hero users have always enjoyed. I expect the first release to be ready in Q4 of 2019.

Optimizing Your Regular Expressions

Regular expressions will backtrack.  That's an unfortunate thing about them because backtracking can be slow.    And in certain (rare) cases the performance can become so awful that executing the regular expression against a relatively short string could take over a minute.  There's a good article about catastrophic backtracking over at . And today I created a video about all of this called  Regex Lesson 5: Optimization .  In the video I start with a very poorly written regular expression and make several improvements to it, using the benchmarking feature along the way.  By the end of the video I make the regular expression over 3 million times faster. In addition, today's update to Regex Hero provides a little message in the event that you encounter a regular expression that takes over 10 seconds to evaluate... And then last of all, I changed the benchmarking feature a bit.  In the past it would simply test your regular expression against

Regex Analysis Bug Fixes

All of these updates relate to the analyzer, so if you're not a Regex Hero Professional user, then this won't affect you. I received a report of an analysis bug  related to character classes.  The regex analyzer wouldn't handle opening brackets inside a character class properly. It's one of the finer details of the regular expression syntax.  You wouldn't think that [[abc] would be valid, but it is.  You don't have to escape the opening bracket inside the character class.  So now the analyzer interprets this as it should. I've also fixed bugs around interpreting the \x00 (hex), \u0000 (unicode), and \k<group>  (backreference) expressions. P.S. The major updates I mentioned recently are still in the works.  So the price for Regex Hero Professional is still $20 for now.