MCPcopy Create free account
hub / github.com/cweijan/vscode-office / syncViewFromCode

Function syncViewFromCode

vditor/src/ts/codeBlock/codeMirrorManager.ts:866–877  ·  view source on GitHub ↗
(binding: CodeMirrorBinding)

Source from the content-addressed store, hash-verified

864 scheduleSync(binding, vditor);
865};
866
867const syncViewFromCode = (binding: CodeMirrorBinding) => {
868 const codeText = binding.syncCode.textContent || "";
869 const cmText = binding.view.state.doc.length ? binding.view.state.doc.toString() : "";
870 if (codeText === cmText) {
871 return;
872 }
873 binding.updating = true;
874 binding.view.dispatch({
875 changes: { from: 0, to: binding.view.state.doc.length, insert: codeText },
876 });
877 binding.updating = false;
878};
879
880const insertLiteralTab = (view: EditorView) => {

Callers 1

mountCodeMirrorFunction · 0.85

Calls 2

toStringMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected