Skip to content

Commit a0d2d20

Browse files
committed
🐛 Ensure modifiable in assign
It seems changing `fileformat` or `fileencoding` cause E21 when `modifiable` is off.
1 parent 30aa472 commit a0d2d20

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

denops_std/buffer/buffer.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ export async function assign(
9898
findFileFormat(text, fileformats) ?? fileformat;
9999
const preprocessor = options.preprocessor ?? ((v: string[]) => v);
100100
const repl = preprocessor(splitText(text, ff));
101-
await batch.batch(denops, async (denops) => {
102-
await fn.setbufvar(denops, bufnr, "&fileformat", ff);
103-
await fn.setbufvar(denops, bufnr, "&fileencoding", enc);
104-
await replace(denops, bufnr, repl);
101+
await modifiable(denops, bufnr, async () => {
102+
await batch.batch(denops, async (denops) => {
103+
await fn.setbufvar(denops, bufnr, "&fileformat", ff);
104+
await fn.setbufvar(denops, bufnr, "&fileencoding", enc);
105+
await replace(denops, bufnr, repl);
106+
});
105107
});
106108
}
107109

0 commit comments

Comments
 (0)