Since each folder is inserted in the page as it is selected, the quotes and parens are closed on the first folder. That way, if user inserts a folder and then hits Esc, the quotes and parens are closed.

> I don't think you want to move the cursor after the quote and closing paren
Correct. This code moves the cursor *before* (not after) the closing quote and/or paren.