ace nits and warning cleanup

- switch to `session.doc.setValue()` when replacing changed file contents - this preserves the undo stack (as per https://github.com/dart-lang/chromedeveditor/issues/1698)
- fix a checked mode issue in ace.dart
- address an analysis warning

@ussuri, @umop 
I'd move this line next to the one where `cursorPos` is actually used below (missed that myself in #3625).