I changed this back to normal priority and severity so I don't seem overly self-important, but I just wanna say that it was wrong for uglyrobot to rush to declare this issue as 'invalid' without looking into it properly.

I also wish to note that another patch to address this problem was just released in 12895 by duck_

I changed this back to normal priority and severity so I don't seem overly self-important, but I just wanna say that it was wrong for uglyrobot to rush to declare this issue as 'invalid' without looking into it properly.

In your sample code you had rewrites commented out. That was expected behavior without defining a rewrite and query_var.

I just noticed that the slug displayed may not be correct, for example, It showed /note/test/ in hte slug preview, and /note/test-6/ after a draft save when it realised test was already taken.

Problem was that autosave.js was not sending a new_slug to admin-ajax.php, if this isn't set then it defaults to empty string. get_sample_permalink(_html) use null as a default for this value, so even though a unique slug was retrieved in the get_sample_permalink function it was overwritten because $name (aka the new_slug) was not null. Fix sets default for unset new_slug to be null. Also move the check for a new name in get_sample_permalink to before the unique slug call so that the same problem doesn't happen when editing the permalink of an existing post (try this now and you'll see that the number suffix isn't added until save).

PS, the patch also includes minor optimisation of _get_page_link function from link-template.php