MCPcopy Index your code
hub / github.com/loggerhead/json4u / getNodeAtPosition

Method getNodeAtPosition

src/lib/editor/editor.ts:293–309  ·  view source on GitHub ↗
(pos: IPosition)

Source from the content-addressed store, hash-verified

291 }
292
293 getNodeAtPosition(pos: IPosition) {
294 const model = this.model();
295
296 if (!(model && this.tree.valid())) {
297 return undefined;
298 }
299
300 const text = this.text();
301
302 // Get the offset of the current cursor in the entire document.
303 let offset = model.getOffsetAt(pos);
304 if (text[offset] === "\n" && text[offset - 1] === ",") {
305 offset--;
306 }
307
308 return this.tree.findNodeAtOffset(offset);
309 }
310
311 // Register a drag event handler to support dragging files to the editor.
312 listenOnDropFile() {

Callers 2

previewProviderMethod · 0.80

Calls 4

modelMethod · 0.95
textMethod · 0.95
validMethod · 0.80
findNodeAtOffsetMethod · 0.80

Tested by

no test coverage detected