* Determines the line and column numbers for a given position in the file. * * @param {string} file - The file content as a string. * @param {number} position - The position in the file for which line and column * numbers are to be determined. * * @returns {Object} An object with 'line' and 'c
(file, position)
| 215 | * // lineColumn: { line: 1, column: 16 } |
| 216 | */ |
| 217 | function getLineColumn(file, position) { |
| 218 | const lines = file.substring(0, position).split("\n"); |
| 219 | const lineNumber = lines.length - 1; |
| 220 | const columnNumber = lines[lineNumber].length; |
| 221 | return { row: lineNumber, column: columnNumber }; |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Retrieves the contents of a file from the main thread. |