@@ -466,9 +466,9 @@ function skipAtomic(target: CommandTarget, pos: number, forward: boolean) {
466
466
return pos
467
467
}
468
468
469
- const deleteByChar = ( target : CommandTarget , forward : boolean ) => deleteBy ( target , range => {
469
+ const deleteByChar = ( target : CommandTarget , forward : boolean , byIndentUnit : boolean ) => deleteBy ( target , range => {
470
470
let pos = range . from , { state} = target , line = state . doc . lineAt ( pos ) , before , targetPos : number
471
- if ( ! forward && pos > line . from && pos < line . from + 200 &&
471
+ if ( byIndentUnit && ! forward && pos > line . from && pos < line . from + 200 &&
472
472
! / [ ^ \t ] / . test ( before = line . text . slice ( 0 , pos - line . from ) ) ) {
473
473
if ( before [ before . length - 1 ] == "\t" ) return pos - 1
474
474
let col = countColumn ( before , state . tabSize ) , drop = col % getIndentUnit ( state ) || getIndentUnit ( state )
@@ -484,11 +484,17 @@ const deleteByChar = (target: CommandTarget, forward: boolean) => deleteBy(targe
484
484
return targetPos
485
485
} )
486
486
487
- /// Delete the selection, or, for cursor selections, the character
488
- /// before the cursor.
489
- export const deleteCharBackward : Command = view => deleteByChar ( view , false )
487
+ /// Delete the selection, or, for cursor selections, the character or
488
+ /// indentation unit before the cursor.
489
+ export const deleteCharBackward : Command = view => deleteByChar ( view , false , true )
490
+
491
+ /// Delete the selection or the character before the cursor. Does not
492
+ /// implement any extended behavior like deleting whole indentation
493
+ /// units in one go.
494
+ export const deleteCharBackwardStrict : Command = view => deleteByChar ( view , false , false )
495
+
490
496
/// Delete the selection or the character after the cursor.
491
- export const deleteCharForward : Command = view => deleteByChar ( view , true )
497
+ export const deleteCharForward : Command = view => deleteByChar ( view , true , false )
492
498
493
499
const deleteByGroup = ( target : CommandTarget , forward : boolean ) => deleteBy ( target , range => {
494
500
let pos = range . head , { state} = target , line = state . doc . lineAt ( pos )
0 commit comments