|
|
@ -8,16 +8,20 @@ export class BlockDetector {
|
|
|
|
const position = this.editor.selection.active;
|
|
|
|
const position = this.editor.selection.active;
|
|
|
|
const doc = this.editor.document;
|
|
|
|
const doc = this.editor.document;
|
|
|
|
|
|
|
|
|
|
|
|
let startLine = doc.lineAt(position.line-1);
|
|
|
|
let startLine = null;
|
|
|
|
let endLine = doc.lineAt(position.line);
|
|
|
|
if (position.line == 0) {
|
|
|
|
|
|
|
|
startLine = doc.lineAt(position.line);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
startLine = doc.lineAt(position.line-1);
|
|
|
|
while (!startLine.isEmptyOrWhitespace && startLine.lineNumber > 0) {
|
|
|
|
while (!startLine.isEmptyOrWhitespace && startLine.lineNumber > 0) {
|
|
|
|
startLine = doc.lineAt(startLine.lineNumber-1)
|
|
|
|
startLine = doc.lineAt(startLine.lineNumber-1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (startLine.isEmptyOrWhitespace) {
|
|
|
|
if (startLine.isEmptyOrWhitespace) {
|
|
|
|
startLine = doc.lineAt(startLine.lineNumber+1)
|
|
|
|
startLine = doc.lineAt(startLine.lineNumber+1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let endLine = doc.lineAt(position.line);
|
|
|
|
let createMatch = startLine.text.match(/create\s+(or\s+replace\s+)?(\w+)\s+(\S+)/)
|
|
|
|
let createMatch = startLine.text.match(/create\s+(or\s+replace\s+)?(\w+)\s+(\S+)/)
|
|
|
|
if (createMatch) {
|
|
|
|
if (createMatch) {
|
|
|
|
while (!endLine.text.match("end " + createMatch[3] + ";") && endLine.lineNumber < doc.lineCount-1) {
|
|
|
|
while (!endLine.text.match("end " + createMatch[3] + ";") && endLine.lineNumber < doc.lineCount-1) {
|
|
|
|