MCPcopy
hub / github.com/antonmedv/codejar / handleTabCharacters

Function handleTabCharacters

codejar.ts:380–400  ·  view source on GitHub ↗
(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

378 }
379
380 function handleTabCharacters(event: KeyboardEvent) {
381 if (event.key === 'Tab') {
382 preventDefault(event)
383 if (event.shiftKey) {
384 const before = beforeCursor()
385 let [padding, start] = findPadding(before)
386 if (padding.length > 0) {
387 const pos = save()
388 // Remove full length tab or just remaining padding
389 const len = Math.min(options.tab.length, padding.length)
390 restore({start, end: start + len})
391 document.execCommand('delete')
392 pos.start -= len
393 pos.end -= len
394 restore(pos)
395 }
396 } else {
397 insert(options.tab)
398 }
399 }
400 }
401
402 function handleUndoRedo(event: KeyboardEvent) {
403 if (isUndo(event)) {

Callers 1

CodeJarFunction · 0.85

Calls 6

preventDefaultFunction · 0.85
beforeCursorFunction · 0.85
findPaddingFunction · 0.85
saveFunction · 0.85
restoreFunction · 0.85
insertFunction · 0.85

Tested by

no test coverage detected