(source:{type:string})
| 1372 | } |
| 1373 | |
| 1374 | formatBlock(source:{type:string}) { |
| 1375 | this.finalizeLastHistoryEntry(); |
| 1376 | let doc = this.cm.getDoc(); |
| 1377 | this.cm.operation(() => { |
| 1378 | let from = {line: doc.getCursor("from").line, ch: 0}; |
| 1379 | let to = {line: doc.getCursor("to").line + 1, ch: 0}; |
| 1380 | |
| 1381 | if(doc.getLine(to.line) !== "") { |
| 1382 | let cursor = doc.getCursor(); |
| 1383 | doc.replaceRange("\n", to, to, "+normalize"); |
| 1384 | doc.setCursor(cursor); |
| 1385 | } |
| 1386 | |
| 1387 | // Determine if a block span in this range already exists. |
| 1388 | let exists:Span|undefined; |
| 1389 | let existing = this.findSpansAt(from, source.type); |
| 1390 | for(let span of existing) { |
| 1391 | let loc = span.find(); |
| 1392 | if(!loc) continue; |
| 1393 | exists = span; |
| 1394 | break; |
| 1395 | } |
| 1396 | |
| 1397 | // If the span already exists, we mean to clear it. |
| 1398 | if(exists) { |
| 1399 | exists.clear(); |
| 1400 | |
| 1401 | // We're creating a new span. |
| 1402 | } else { |
| 1403 | |
| 1404 | // Block formats are exclusive, so we clear intersecting spans of other types. |
| 1405 | let spans = this.findSpans(doc.posFromIndex(doc.indexFromPos(from) - 1), to); |
| 1406 | for(let span of spans) { |
| 1407 | if(span.isEditorControlled()) { |
| 1408 | span.clear(); |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | this.formatSpan(from, to, source); |
| 1413 | } |
| 1414 | }); |
| 1415 | } |
| 1416 | |
| 1417 | trackDenormalized(span:Span) { |
| 1418 | if(span.isDenormalized) { |
no test coverage detected