MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getLineColumn

Function getLineColumn

src/sidebarApps/searchInFiles/worker.js:217–222  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

215 * // lineColumn: { line: 1, column: 16 }
216 */
217function 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.

Callers 1

searchInFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected