(newSource: string)
| 1160 | } |
| 1161 | |
| 1162 | updateSource(newSource: string): void { |
| 1163 | // Create something that looks like an edit operation for the whole text |
| 1164 | const operation = { |
| 1165 | range: this.editor.getModel()!.getFullModelRange(), |
| 1166 | forceMoveMarkers: true, |
| 1167 | text: newSource, |
| 1168 | }; |
| 1169 | this.applyEdit(operation); |
| 1170 | |
| 1171 | if (!this.awaitingInitialResults) { |
| 1172 | if (this.selection) { |
| 1173 | /* |
| 1174 | * this setTimeout is a really crap workaround to fix #2150 |
| 1175 | * the TL;DR; is that we reach this point *before* GL has laid |
| 1176 | * out the window, so we have no height |
| 1177 | * |
| 1178 | * If we revealLinesInCenter at this point the editor "does the right thing" |
| 1179 | * and scrolls itself all the way to the line we requested. |
| 1180 | * |
| 1181 | * Unfortunately the editor thinks it is very small, so the "center" |
| 1182 | * is the first line, and when the editor does resize eventually things are off. |
| 1183 | * |
| 1184 | * The workaround is to just delay things "long enough" |
| 1185 | * |
| 1186 | * This is bad and I feel bad. |
| 1187 | */ |
| 1188 | setTimeout(() => { |
| 1189 | if (this.selection) { |
| 1190 | this.editor.setSelection(this.selection); |
| 1191 | this.editor.revealLinesInCenter(this.selection.startLineNumber, this.selection.endLineNumber); |
| 1192 | } |
| 1193 | }, 500); |
| 1194 | } |
| 1195 | this.awaitingInitialResults = true; |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | formatCurrentText(): void { |
| 1200 | const previousSource = this.getSource(); |
no test coverage detected