| 263 | super().__init__(parent, token.start, token.end, token.initial_text) |
| 264 | |
| 265 | def _update(self, done, buf): |
| 266 | path = vim_helper.eval('expand("%")') or "" |
| 267 | ct = self.current_text |
| 268 | self._locals.update( |
| 269 | { |
| 270 | "t": _Tabs(self._parent), |
| 271 | "fn": Path(path).name, |
| 272 | "path": path, |
| 273 | "cur": ct, |
| 274 | "res": ct, |
| 275 | "snip": self._snip, |
| 276 | } |
| 277 | ) |
| 278 | self._snip._reset(ct) |
| 279 | |
| 280 | for code, compiled_code in zip(self._codes, self._compiled_codes, strict=True): |
| 281 | try: |
| 282 | exec(compiled_code, self._locals) |
| 283 | except Exception as exception: |
| 284 | exception.snippet_code = code |
| 285 | raise |
| 286 | |
| 287 | rv = str(self._snip.rv if self._snip._rv_changed else self._locals["res"]) |
| 288 | |
| 289 | if ct != rv: |
| 290 | self.overwrite(buf, rv) |
| 291 | return False |
| 292 | return True |