MCPcopy Create free account
hub / github.com/microsoft/typescript-go / Backspace

Method Backspace

internal/fourslash/fourslash.go:3706–3719  ·  view source on GitHub ↗

Removes the text at the current caret position as if the user pressed backspace `count` times.

(t *testing.T, count int)

Source from the content-addressed store, hash-verified

3704
3705// Removes the text at the current caret position as if the user pressed backspace `count` times.
3706func (f *FourslashTest) Backspace(t *testing.T, count int) {
3707 script := f.getScriptInfo(f.activeFilename)
3708 offset := int(f.converters.LineAndCharacterToPosition(script, f.currentCaretPosition))
3709 f.baselineState(t)
3710
3711 for range count {
3712 offset--
3713 f.editScriptAndUpdateMarkers(t, f.activeFilename, offset, offset+1, "")
3714 f.currentCaretPosition = f.converters.PositionToLineAndCharacter(script, core.TextPos(offset))
3715 // Don't need to examine formatting because there are no formatting changes on backspace.
3716 }
3717
3718 // f.checkPostEditInvariants() // !!! do we need this?
3719}
3720
3721// DeleteAtCaret removes the text at the current caret position as if the user pressed delete `count` times.
3722func (f *FourslashTest) DeleteAtCaret(t *testing.T, count int) {

Calls 7

getScriptInfoMethod · 0.95
baselineStateMethod · 0.95
TextPosTypeAlias · 0.92
intInterface · 0.50