MCPcopy Create free account
hub / github.com/Marus/cortex-debug / getOffset

Method getOffset

src/frontend/memory_content_provider.ts:150–166  ·  view source on GitHub ↗
(pos: vscode.Position)

Source from the content-addressed store, hash-verified

148 public lastAsciiPos: number = this.firstAsciiPos + 16;
149
150 private getOffset(pos: vscode.Position): number {
151 // check if within a valid section
152 if (pos.line < 1 || pos.character < this.firstBytePos) {
153 return;
154 }
155
156 let offset = (pos.line - 1) * 16;
157 const s = pos.character - this.firstBytePos;
158 if (pos.character >= this.firstBytePos && pos.character <= this.lastBytePos) {
159 // byte section
160 offset += Math.floor(s / 3);
161 } else if (pos.character >= this.firstAsciiPos) {
162 // ascii section
163 offset += (pos.character - this.firstAsciiPos);
164 }
165 return offset;
166 }
167
168 private getPosition(offset: number, ascii: boolean = false): vscode.Position {
169 const row = 1 + Math.floor(offset / 16);

Callers 1

handleSelectionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected