Spaces:
Sleeping
Sleeping
Download web/src/columns.js from brianbellx/codehygiene: direct link, hf CLI and curl.
- Browser
- Download file 727 Bytes
-
https://huggingface.co/spaces/brianbellx/codehygiene/resolve/main/web/src/columns.js
- Command line
-
hf download hf://spaces/brianbellx/codehygiene/web/src/columns.js
-
curl -L -o columns.js https://huggingface.co/spaces/brianbellx/codehygiene/resolve/main/web/src/columns.js
727 Bytes
| const TAB_STOP = 2; | |
| export function scorerSpanToOffsets(lineText, colStart, colEnd) { | |
| const startCol = colStart - 1; | |
| const endCol = colEnd - 1; | |
| let expandedCol = 0; | |
| let from = null; | |
| let index = 0; | |
| while (index < lineText.length) { | |
| const char = String.fromCodePoint(lineText.codePointAt(index)); | |
| const width = char === "\t" ? TAB_STOP - (expandedCol % TAB_STOP) : 1; | |
| const nextCol = expandedCol + width; | |
| if (from === null && nextCol > startCol) { | |
| from = index; | |
| } | |
| if (nextCol > endCol) { | |
| return { from, to: index + char.length }; | |
| } | |
| expandedCol = nextCol; | |
| index += char.length; | |
| } | |
| const lineEnd = lineText.length; | |
| return { from: from ?? lineEnd, to: lineEnd }; | |
| } | |