* @param {import("../diff").DiffModel} [diffModel] - The model for the diff view.
(diffModel)
| 70 | * @param {import("../diff").DiffModel} [diffModel] - The model for the diff view. |
| 71 | */ |
| 72 | $setupModels(diffModel) { |
| 73 | if (diffModel.diffProvider) { |
| 74 | this.setProvider(diffModel.diffProvider); |
| 75 | } |
| 76 | this.showSideA = diffModel.inline == undefined ? true : diffModel.inline === "a"; |
| 77 | var diffEditorOptions = /**@type {Partial<import("../../../ace-internal").Ace.EditorOptions>}*/({ |
| 78 | scrollPastEnd: 0.5, |
| 79 | highlightActiveLine: false, |
| 80 | highlightGutterLine: false, |
| 81 | animatedScroll: true, |
| 82 | customScrollbar: true, |
| 83 | vScrollBarAlwaysVisible: true, |
| 84 | fadeFoldWidgets: true, |
| 85 | showFoldWidgets: true, |
| 86 | selectionStyle: "text", |
| 87 | }); |
| 88 | |
| 89 | this.savedOptionsA = diffModel.editorA && diffModel.editorA.getOptions(diffEditorOptions); |
| 90 | this.savedOptionsB = diffModel.editorB && diffModel.editorB.getOptions(diffEditorOptions); |
| 91 | |
| 92 | if (!this.inlineDiffEditor || diffModel.inline === "a") { |
| 93 | this.editorA = diffModel.editorA || this.$setupModel(diffModel.sessionA, diffModel.valueA); |
| 94 | this.container && this.container.appendChild(this.editorA.container); |
| 95 | this.editorA.setOptions(diffEditorOptions); |
| 96 | } |
| 97 | if (!this.inlineDiffEditor || diffModel.inline === "b") { |
| 98 | this.editorB = diffModel.editorB || this.$setupModel(diffModel.sessionB, diffModel.valueB); |
| 99 | this.container && this.container.appendChild(this.editorB.container); |
| 100 | this.editorB.setOptions(diffEditorOptions); |
| 101 | } |
| 102 | |
| 103 | if (this.inlineDiffEditor) { |
| 104 | this.activeEditor = this.showSideA ? this.editorA : this.editorB; |
| 105 | this.otherSession = this.showSideA ? this.sessionB : this.sessionA; |
| 106 | var cloneOptions = this.activeEditor.getOptions(); |
| 107 | cloneOptions.readOnly = true; |
| 108 | delete cloneOptions.mode; |
| 109 | this.otherEditor = new Editor(new Renderer(null), undefined, cloneOptions); |
| 110 | if (this.showSideA) { |
| 111 | this.editorB = this.otherEditor; |
| 112 | } else { |
| 113 | this.editorA = this.otherEditor; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | this.setDiffSession({ |
| 118 | sessionA: diffModel.sessionA || (diffModel.editorA ? diffModel.editorA.session : new EditSession( |
| 119 | diffModel.valueA || "")), |
| 120 | sessionB: diffModel.sessionB || (diffModel.editorB ? diffModel.editorB.session : new EditSession( |
| 121 | diffModel.valueB || "")), |
| 122 | chunks: [] |
| 123 | }); |
| 124 | |
| 125 | if (this.otherEditor && this.activeEditor) { |
| 126 | this.otherSession.setOption("wrap", this.activeEditor.getOption("wrap")); |
| 127 | } |
| 128 | |
| 129 | this.setupScrollbars(); |
no test coverage detected