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