@@ -13557,6 +13557,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
1355713557 //
1355813558 // Find out who called this function
1355913559 //
13560+ //debugger
1356013561 let stackTrace = yz.uiDb.getCallStack()
1356113562 let fnLine = stackTrace[2]
1356213563 console.log(fnLine)
@@ -13682,13 +13683,15 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
1368213683 //
1368313684 // do nothing if not in debug mode
1368413685 //
13686+
1368513687 if ((typeof $DEBUGUI == 'undefined') || (!$DEBUGUI)) {
1368613688 return
1368713689 }
1368813690
1368913691 //
1369013692 // reset all the debug markers as we are starting a new debug trace
1369113693 //
13694+ debugger
1369213695 yz.debug.currentDebugId = debugId
1369313696 yz.debug.debugTracerId = yz.uuidv4()
1369413697 yz.debug.debugTraceSteps = []
@@ -13698,7 +13701,7 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
1369813701 //
1369913702 // Find out which source code line we are editing
1370013703 //
13701- debugger
13704+ // debugger
1370213705 let sourceForFunction = yz.uiDb.findSourceLineInCode(debugId)
1370313706
1370413707 //
@@ -14090,6 +14093,60 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
1409014093 [yz.uiDb.uiDbNextId ++,result.fileName,result.contents])
1409114094 yz.debug.linesOfSourceFile[result.fileName] = result.contents.split('\n');
1409214095 },
14096+ findDebugIdInCode: function ( searchText ) {
14097+ let found = false
14098+ let startLine = null
14099+ let endLine = null
14100+ let foundLine = null
14101+ let foundFile = null
14102+ let lineNumberOfSearchItem = null
14103+ let surroundingLines = null
14104+
14105+ for (let fileSourceRecord of yz.uiDb.uiDbTableData["ui_table_command_source_files"].data) {
14106+ console.log("Searching " + fileSourceRecord.source_file_name)
14107+ let indexOfSearch = fileSourceRecord.source_text.indexOf(searchText)
14108+
14109+ if ( indexOfSearch != -1 ) {
14110+ console.log(" Found '" + searchText + "' at index " + indexOfSearch)
14111+ found = true
14112+ foundFile = fileSourceRecord.source_file_name
14113+
14114+ let textUpToSearchItem = fileSourceRecord.source_text.substring(0,indexOfSearch)
14115+ let linesOfFileBeforeSearchItem = textUpToSearchItem.split('\n');
14116+ lineNumberOfSearchItem = linesOfFileBeforeSearchItem.length
14117+
14118+ let linesOfFile = yz.debug.linesOfSourceFile[fileSourceRecord.source_file_name]
14119+
14120+ startLine = lineNumberOfSearchItem - 5
14121+ if (startLine < 1) {
14122+ startLine = 1
14123+ }
14124+ endLine = lineNumberOfSearchItem + 5
14125+ if (endLine > linesOfFile.length) {
14126+ endLine = linesOfFile.length
14127+ }
14128+
14129+ for (let currentLineNumber = startLine; currentLineNumber <= endLine ; currentLineNumber ++) {
14130+ let currentLine = linesOfFile[currentLineNumber - 1]
14131+
14132+ let existsRow = yz.uiDb.sqlui1("select id from ui_table_command_source_file_lines where source_file_name= ? and source_line_number = ?",
14133+ [fileSourceRecord.source_file_name , currentLineNumber])
14134+ if (!existsRow) {
14135+ yz.uiDb.sqlui("INSERT INTO ui_table_command_source_file_lines ( id , source_file_name , source_line_text , source_line_number ) VALUES (?,?,?,?)",
14136+ [yz.uiDb.uiDbNextId ++,fileSourceRecord.source_file_name, currentLine, currentLineNumber])
14137+ }
14138+ }
14139+ console.log("Filename: " + fileSourceRecord.source_file_name)
14140+ foundLine = linesOfFile[lineNumberOfSearchItem - 1]
14141+ console.log(" foundOnLine: " + lineNumberOfSearchItem + ":" + foundLine)
14142+
14143+ surroundingLines = sqlui("select * from ui_table_command_source_file_lines where source_file_name = ? and source_line_number >= ? and source_line_number <= ?",[foundFile, startLine, endLine])
14144+
14145+ break
14146+ }
14147+ }
14148+ return { found: found , fileName: foundFile, lineNumber: lineNumberOfSearchItem, lineText: foundLine , context: surroundingLines }
14149+ },
1409314150 findSourceLineInCode: function ( searchText ) {
1409414151 let found = false
1409514152 let startLine = null
0 commit comments