void () { String text = "a\n<caret>b\n#%%\nc"; // ^^^^^^^ <- guarded // com.intellij.openapi.editor.actions.DocumentGuardedTextUtil.deleteString handles this case and removes \n before caret myFixture.configureByText("x.txt", text); RangeMarker guard = createGuard(3, 8); myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DELETE_LINE); myFixture.checkResult("a\n#%%\nc"); assertTrue(guard.isValid()); assertEquals(1, guard.getStartOffset()); assertEquals(6, guard.getEndOffset()); }