When trying to simply rename an item in an anvil, the item will snap back to the first slot and return to its original state.
When trying to rename an item along with an enchantment (or any other anvil uses, such as repairing), the item will retain all changes except the new name.
Environment
Windows 8.1 (64-bit), Java 8 update 144 (64-bit)
Duplicate of MC-121638