"Interesting" Notepad Bug

CraigBlog

Syndication

I've been writing my own text editor control. Although only a moron would actually do this, I'm learning a lot along the way. One of the toughest bits of it is to correctly implement word wrapping, particularly because I want to get it right not just for ASCII characters, but for others as well, like East Asian languages. (While I may be a moron, I'm not insane: I'm using the Uniscribe API to do all the hard parts.)

One of my challenges is that I don't always know what the “right” way to do something is. For example, should there be an invisible character representing the newline that shows up when drag selecting? Should the width of this character count against word wrapping?

When faced with a challenge like this, I often fire up another program and see what its authors decided to do. One of these that I frequently consult is Word. Another is Notepad. I figure I ought to at least be able to provide what Notepad does, and at best I'd match the capabilities of Word (although I'm not quite so mad as to actually target that). Well, tonight as I was trying to work out the kinks in my word breaking algorithm, I saw an interesting quirk in Notepad's line breaking capabilities. It surprised me because I assume Notepad to be one of the most mature pieces of software in Windows. Anyway, try this:

  1. Fire up Notepad.
  2. Make sure that Word Wrap is enabled.
  3. Type some gibberish that has some spaces in it.
  4. As soon as you type something that wraps to the next line, start hitting backspace.
  5. Note that backspacing to the point where the word that wrapped becomes short enough that it could fit on the previous line does not actually “unwrap“.
  6. Marvel that the amount of utility in this information is so small as to be undetectable by modern scientific instruments. :)

Posted Mar 19 2005, 09:13 PM by craig-andera

Comments

Aaron B. Hockley wrote re: "Interesting" Notepad Bug
on 03-19-2005 8:13 PM
I think that most "power users" and developers don't use notepad much (I use notepad2) and most likely they are the only ones who might worry about such a thing.

That said, you do have to chuckle, because Notepad was around in Windows 3.0 (or possibly before)?
Craig wrote re: "Interesting" Notepad Bug
on 03-20-2005 3:35 AM
I use Notepad2 myself. But Notepad2 is based around Scintilla, which has a whole raft of bugs (although it's still a great control). That's why I was observing Notepad, rather than Notepad2.
anonymous wrote re: "Interesting" Notepad Bug
on 03-20-2005 10:08 AM
Let's go ahead and crush any last illusion of notepad's technical excellence... here's a related bug. More like a punted feature, perhaps, but so lame I consider it a bug:

-- start notepad
-- disable wordwrap, if not already
-- enable statusbar
-- type some junk
-- (re)enable wordwrap

What? No statusbar? Try to reenable it. No can do!

I have it on good authority that notepad was misreporting the line number when ww was enabled, this bug was only noticed shortly before XP shipped, and the only thing they could do w/o resetting escrow testing was to disable the statusbar+wordwrap combo. Groan..
Craig wrote re: "Interesting" Notepad Bug
on 03-20-2005 12:24 PM
Heh. Yeah, I suspect Notepad bugs don't get real high on the priority list.

BTW, if you haven't tried Notepad2, you really ought to. It's free.
Brandon Furtwangler wrote re: "Interesting" Notepad Bug
on 03-24-2005 6:52 AM
Do you mind if I pretend I discovered this bug to impress the ladies? :-p
Craig wrote re: "Interesting" Notepad Bug
on 03-24-2005 7:11 PM
Be my guest: I already caught my limit. ;)
Robbie wrote re: "Interesting" Notepad Bug
on 08-01-2005 9:39 PM
Really buggy Notepad.
Once upon a time, I have been using notepad to write HTML documents. I usually turn Word Wrap on. During the use, misterious bugs showed up in Notepad - sometimes the cursor can be moved to some position where nothing exists, and if I typed something, they would appear together with some text on the next line. In the end, I found it is that when a file is saved, it updated the word wrapped layout internally (with something just you said, type some gibberish that has some spaces in it, and then backspace to), but it did not refresh the display.
JDeep wrote re: "Interesting" Notepad Bug
on 09-20-2005 12:32 AM
Hmmm notepad exists from win 3.1 and it's not fixed yet?! If microsoft is not able to develop a "word wrap" i'm worrying about vista :(
Craig wrote re: "Interesting" Notepad Bug
on 09-20-2005 4:29 AM
That line of reasoning is a bit faulty. For one thing, it assumes that notepad and vista are equivalent in importance to Microsoft. For another it assumes that vista and notepad are equivalent in functionality. Neither is true.

Anyone who's expecting Vista to be bug-free is going to be surprised. However, I expect it to be a high-quality product, in line with the increasing stability we've experienced in Microsoft products historically.
JDeep wrote re: "Interesting" Notepad Bug
on 09-23-2005 7:14 PM
Notepad is part of these easy tools one can want to use at anytime - and it is usually run by default to open txt files...

How come such an *obvious* bug of such a useful application can be let unfixed ?

Of course, this is not a ludicrous Vista vs Notepad comparison... Notepad could be fixed in 10 minutes, it just show in which spirit microsoft develops its applications.
Notepad is so simple its flaws can be easily detected ; but what about the internal kernel of an OS? it's a black box where nobody but some engineers can look inside (unlike Linux that can be seen by anybody)...
I agree the reliability of the OS is increasing, but what does it cost? Why is it slow? Why "wine" on Linux does the same thing faster? Because you cannot see inside bugs fixed with "band aid".
If Notepad fails, "well just dont use the word wrap option", what if the OS fails? The computer stops, so it has to be fixed.
Just a question of spirit...
Craig wrote re: "Interesting" Notepad Bug
on 09-24-2005 4:59 AM
If you think Notepad is simple, you should try writing a clone. I'm writing a text editor control right now, and it turns out there are lots of complex issues to deal with, *especially* around things like word wrapping, left to right, etc.

I'm a big fan of open source. I've worked on several major projects myself. And interestingly, I find that the quality of open source is generally far worse than that of Microsoft's software. There are a few exceptions, but that's the general rule.
JDeep wrote re: "Interesting" Notepad Bug
on 09-25-2005 9:11 PM
I must agree that MS did some good stuff, Excel for instance (while openOffice is great as well... and free.)

The good thing about open source is that everybody (meaning all developpers) can fix bugs, or implements their own version. The bad think is that some software fit only the needs of a particular home developper where no manager had to cope with requirements and explain himself to somebody. And some useful programs are really painful for that (being too specific and not coping with general needs).

However the main MS softs get a good equivalent on the open source side (eg did you check out the latest SuSE?). And I prefer a less "sexy" tool that is free and that is customizable than something expensive and opaque.

Well, being a developper myself, working on both platforms, let me tell you that the MS tendancy to keep its software structure as a black box is really annoying. MS became such a big company that their APIs and documentation lack of consistency. Most of the time, I better get the free open source library to fit my needs than trying to cope with MS specifities/inconsistencies/ambiguous doc/bugs/"need to upgrade to latest $$ version" not mentioning the weirdness of some of their internal implementations...

From the user side, Windows is used at so many places that anyone will always (for the time being) be able to find a needed program to do something in particular.

From a developper perspective, MS shows a lot of weaknesses which are not visible from the outside: their management. Imho, MS gets a handle (or a bit more) of very competent people working on the OS kernel in a well managed structured team. For the rest, including the top, they grew during the very profitable years of MS (say, up to a few years from now) and have no idea of what is a good management. How could they personnaly acknowledge this, especially while the company is still making a huge profit (resting on their laurels)...? Time will tell.

Imho, MS key people, being insanely paid, will feel more and more the terrible frustration of being in this company *only* for the money.

What makes a good movie is first its direction, not (only) the money that can be invested in.

Oh maybe i'm wandering a bit off the point...
RDL Dev Inc wrote re: "Interesting" Notepad Bug
on 10-01-2005 5:48 AM
N2 is a great replacement for the original. How many times have you needed a dual clipboard, since N2 comes with the source this is a great chance to add it! I wonder why this feature goes overlooked with so many editors?

Al wrote re: "Interesting" Notepad Bug
on 10-20-2005 7:55 PM
Get emacs and be done with it (unless you are hardcore and want to use Vi - ugh modes)
Craig wrote re: "Interesting" Notepad Bug
on 10-21-2005 4:55 AM
I use emacs every day. I've even written several major modes for it. :)
Annoyed wrote re: "Interesting" Notepad Bug
on 11-01-2005 8:26 PM
Notepad got buggy in Windows XP. In earlier versions of Windows it actually worked; but no longer.
DHS wrote re: "Interesting" Notepad Bug
on 06-14-2006 9:26 PM
here's another bug

type in 3 characters lowercase
hit the spacebar

type in 4 characters lowercase
hit the spacebar

type in 3 characters lowercase
hit the spacebar

type in 5 character lowercase
SAVE THE FILE

close the file

reopen it.

what do u see???
Animesh wrote re: "Interesting" Notepad Bug
on 06-19-2006 2:41 AM
Well for opensource.....Coding is not worse....

Don't you know...Microsoft's so called Innovation comes from Open Source IDeaz only...
Where do you think ASP.NET Came from....
Heard of Struts Framework...Which came back a year earlier...

Heard of Java in 1997...CLR Clone of JVM.....

It's easy to put a price tag on something...by decorating it....
Decorator pattern applies to these guys........Nothing else...and you pay for it....tats why...they work so hard to make the software.....with all glitz and glamour...

Remember all that glitters is not gold!

Craig wrote re: "Interesting" Notepad Bug
on 06-19-2006 3:09 AM
Animesh: this is one of the oldest claims in the book. It is neither wholly true nor wholly false. And in any event it is completely irrelevant - every piece of interesting software looks a lot like something that came before it. Including all the "open source" projects you site (the JVM is *definitely* not open source).
sejal wrote re: "Interesting" Notepad Bug
on 06-20-2006 4:40 AM
i got a fwd saying the below:
Hi guys,
Try this...Bug

For those of you using Windows, do the following:

1.) Open an empty notepad file
2.) Type "Bush hid the facts" (without the quotes)
3.) Save it

4.) Close it, and re-open it.

Any explanation to the above?

Craig wrote re: "Interesting" Notepad Bug
on 06-20-2006 6:40 AM
Yeah. This: http://blogs.msdn.com/michkap/archive/2006/06/14/631016.aspx
Animesh wrote re: "Interesting" Notepad Bug
on 06-29-2006 12:58 AM
Actualy u can also type....

ZZZZ ZZZ ZZZ ZZZZZ

Any letter in place of 'Z' or mixed combination!
Richard Kagerer wrote re: "Interesting" Notepad Bug
on 08-30-2006 7:50 PM
Has anybody else run into a problem pasting large amounts of text from notepad into another program (e.g. Word) and getting odd line breaks inserted for you? It doesn't occur if you turn Word Wrap off before copying the text. It seems the "soft" line breaks are getting copied with the text as "hard" line breaks.

Microsoft has a lot of money. This may sound harsh, but if they didn't have the competence to fix Notepad in a timely fashion (how many years has it been now since XP was released? 3? 4?), then they should simply have bought out a working notepad program from some small company. It would be a pittance in the long term.

Cheers,

-Richard
Brad wrote re: "Interesting" Notepad Bug
on 09-10-2006 1:28 PM
Microsoft should fix notepad to help scientifically minded developers. Pure text is the way to go.
Dimitar wrote re: "Interesting" Notepad Bug
on 09-15-2006 10:37 AM
If you want free BEST notepad, try NOTEPAD++
Best for Developers, designers, programmers...
Nikhil Mathew wrote re: "Interesting" Notepad Bug
on 09-28-2006 1:11 AM
Blaming Microsoft on a tiny notepad bug is not logic. And think of it in this way, all the programmers there at Microsoft are not not Gods. They too does mistakes like we all do.(if u are a programmer, u know...). This doesn't mean that Bill Gates planned a bug in XP notepad so that he can sell Vista fixing it. Open Source and free softwares are nice to talk about. If the standard of those softwares exceeds that of Microsoft, why Bill Gates remains the richest ?
Damien wrote re: "Interesting" Notepad Bug
on 10-17-2006 5:12 PM


I use Notepad++ to replace Notepad :
http://notepad-plus.sourceforge.net/

The reason I use Notepad++ is its MDI (Multi-Document Interface just like firefox).

To replace your notepad by notepad++, you have to :

1. Download and install Notepad++ :
http://internap.dl.sourceforge.net/sourceforge/notepad-plus/npp.3.9.Installer.exe
2. Download Notepad++ launcher :
http://notepad-plus.sourceforge.net/commun/misc/NppLauncher.bin.zip
3. Copy notepad.exe which comes with this package into 3 directories (in given order) :

i. c:\windows\system32\dllcache
ii. c:\windows\system32
iii. c:\windows

When you replace notepad.exe in c:\windows\system32 and c:\windows, a "Windows File Protection" message box appears, click Cancel. Then another message box appears, click OK.

Now Notepad++ is your default Notepad.
anon wrote re: "Interesting" Notepad Bug
on 12-19-2006 10:49 AM
" # re: "Interesting" Notepad Bug
anonymous
Posted @ 3/20/2005 12:08 PM
Let's go ahead and crush any last illusion of notepad's technical excellence... here's a related bug. More like a punted feature, perhaps, but so lame I consider it a bug:

-- start notepad
-- disable wordwrap, if not already
-- enable statusbar
-- type some junk
-- (re)enable wordwrap

What? No statusbar? Try to reenable it. No can do!

I have it on good authority that notepad was misreporting the line number when ww was enabled, this bug was only noticed shortly before XP shipped, and the only thing they could do w/o resetting escrow testing was to disable the statusbar+wordwrap combo. Groan.. "

This is complete rubbish - if you enable line-wrapping and line numbering together you have a conflict of interest. Do you split the line numbers such that there are gaps when wrapping occurs or do you ignore the wrapping and ensure there are no gaps in the line numbers - MS made the decision not to allow the conflict, it's NOT a bug!
K F wrote re: "Interesting" Notepad Bug
on 01-23-2007 2:56 AM
"Microsoft has a lot of money. This may sound harsh, but if they didn't have the competence to fix Notepad in a timely fashion (how many years has it been now since XP was released? 3? 4..."

Absolutely right, Richard. Microsoft has made its billions by ripping people off. Fundamental functionality (e.g. search in Explorer) has been broken and never fixed for years. Gates and Ballmer are rich because they are nothing more than criminals.

If you look at any individual or company that has accumulated fantastic amounts of money, you'll see there is always some sort of criminal activity at work. It may not strictly be against the letter of the law, but these people should not be sleeping soundly, as they have swindled millions of innocent individuals.
Vish..! wrote err..! check this as well..!
on 07-26-2007 4:35 AM
This day I too encountered some issue with notepad.. donno whether this is a bug or an issue with my machine..!

http://inside-n-outside.blogspot.com/2007/07/notepad-simple-to-use-but-is-this-bug.html
Samir wrote re: "Interesting" Notepad Bug
on 08-19-2007 4:05 PM
A lot of the word wrap bugs have been around since Windows 3.0. I've used every version, and still do on occasion. It still shocks me to see the same bugs from 3.0 in xp sp2...classic "I don't care" service and support.
Aaron wrote re: "Interesting" Notepad Bug
on 11-13-2007 8:15 PM
For all that notepad is buggy, it is one of the only apps that does codepage handling, AND UTF-8, AND UCS-2 encoding right. As soon as you go outside of ASCII text, 90% of the editors in the world - while nice and full of features - either crash or display junk. Another 9% of editors will handle UTF-8 as well, but not non-Unicode MBCS (multi-byte character sets, such as Chinese).

Even Emacs, the supposed benchmark of hard-code text editing, still cannot handle Unicode properly, 20 years later.

Because of this, and because Notepad is on every windows system ever, it still gets used, despite the problems.
Deep wrote re: "Interesting" Notepad Bug
on 04-02-2008 1:30 AM
Hi i tried but didn't see anything.......
haquea wrote re: "Interesting" Notepad Bug
on 06-26-2008 5:12 AM
Microsoft fails to solve these problem- Really Interesting


An Indian discovered that nobody can create a FOLDER anywhere on the computer which can be named as "CON". This is something pretty cool...and unbelievable... At Microsoft the whole Team, couldn't answer why this happened!
TRY IT NOW ,IT WILL NOT CREATE " CON " FOLDER

Folders with name: CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5,
COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, & LPT9
cant be created using Windows Explorer or Command Prompt directly! ( Try this
out.. right click on your desktop and try creating folder named "con"it changes
back to "ew Folder" )

This is prevented as XP terms these folders as SYSTEM Folder Names reserved only
for the Operating System.. But there is a backdoor...(this trick is to create
system folders on XP through command prompt )

Try this:
CREATION

Syntax:md \\.\\$path
Example:prompt>md \\.\\C:\con
Explanation: This would create a folder named "con" on your "C Drive"


Similarly to delete such folder:
DELETION
Syntax:rd/s \\.\\$path
Example:prompt>rd/s \\.\\C:\con
Explanation: This would remove the folder named "con"!
Note: rd(Remove Directory) command is used with "/s" switch as otherwise it
would give error that "folder is not empty"!


On another hand...if you ever wondered how to create a folder with no
name...then try this:

Create a New Folder from Windows Explorer
Select rename & type: "ALT+255"(Use Numpad)..that’s it!
ALT+255 stand for blank character in ASCII...so it still accepts your folder name!


Anonymous wrote re: "Interesting" Notepad Bug
on 07-11-2008 1:27 PM

I have encountered bugs in Notepad in both XP and 98 where lines disappear or text appears on the wrong line. Often selecting all, then de-selecting seems to help. I prefer to use the Text application in the old Tandy DeskMate GUI - Tandy had it right in 1988, Microsoft still can't get it straight 20 years later...

Add a Comment

(required)  
(optional)
(required)  
Remember Me?