In his preface to Summer Lightning, P. G. Wodehouse makes reference to the story that William Makepeace Thackeray had a "eureka moment" in bed wherein he, Thackeray, suddenly had the idea for the title of his novel:
It is related of Thackeray that, hitting upon Vanity Fair after retiring to rest one night, he leaped out of bed and ran seven times round the room, shouting at the top of his voice.
Is this story found in Thackeray's own writings? If not, what is the earliest written source of this story (assuming that Wodehouse did not make it up, even if he may have embellished the "seven times" detail for humorous effect)?