Code completion in pattern matching

Fix #1001284