Package: emacs, cc-mode From 'emacs -Q', eval the following: (with-current-buffer (get-buffer-create "*test*") (erase-buffer) (insert "int main()\n{\n \n}\n") (search-backward "\n}") (c-mode) (save-restriction (narrow-to-region (point) (point)) (insert "foo"))) Gives the backtrace: Debugger entered--Lisp error: (args-out-of-range 1 1) get-text-property(1 c-fl-syn-tab) c-clear-string-fences() #f(compiled-function () #)() c-after-change(16 19 0) insert("foo") (save-restriction (narrow-to-region (point) (point)) (insert "foo")) (save-current-buffer (set-buffer (get-buffer-create "*test*")) (erase-buffer) (insert "int main()\n{\n \n}\n") (search-backward "\n}") (c-mode) (save-restriction (narrow-to-region (point) (point)) (insert "foo"))) This is a reduced test case from https://github.com/joaotavora/eglot/issues/291. I think the obvious fix is to extend the save-restriction just a bit further to cover c-clear-string-fences, patch attached.