_FUNNY = '''\
def foo(
    x,
     y
'''
_DEDENTED = '''\
def foo(
    x,
    y
'''
_BEFORE_Y = '3.5'
_AFTER_Y = '3.6'


# issue 65
def test_dedent_when_misaligned(filetab):
    filetab.settings.set('indent_size', 4)
    filetab.settings.set('tabs2spaces', True)
    filetab.update()

    filetab.textwidget.insert('end', _FUNNY)
    assert filetab.textwidget.dedent(_BEFORE_Y)
    assert filetab.textwidget.get('1.0', 'end - 1 char') == _DEDENTED


# issue 74
def test_doesnt_delete_stuff_far_away_from_cursor(filetab):
    filetab.settings.set('indent_size', 4)
    filetab.settings.set('tabs2spaces', True)
    filetab.update()

    filetab.textwidget.insert('end', _FUNNY)
    assert not filetab.textwidget.dedent(_AFTER_Y)
    assert filetab.textwidget.get('1.0', 'end - 1 char') == _FUNNY


def test_dedent_start_of_line(filetab):
    filetab.settings.set('indent_size', 4)

    for tabs2spaces in [True, False]:
        filetab.settings.set('tabs2spaces', tabs2spaces)
        filetab.update()

        filetab.textwidget.insert('end', (' '*4 if tabs2spaces else '\t') + 'a')
        assert filetab.textwidget.dedent('1.0')
        assert filetab.textwidget.get('1.0', 'end - 1 char') == 'a'
        assert not filetab.textwidget.dedent('1.0')
        assert filetab.textwidget.get('1.0', 'end - 1 char') == 'a'
        filetab.textwidget.delete('1.0', 'end')

@@ -1,12 +1,29 @@
+import platform%0A%0A
 _FUNNY = '''
@@ -1377,8 +1377,791 @@
  'end')%0A
+%0A%0Adef test_indent_block_plugin(filetab):%0A    filetab.textwidget.insert('1.0', '''%5C%0Afoo%0Abar%0Abiz%0Abaz''')%0A    filetab.textwidget.tag_add('sel', '2.1', '3.2')%0A    filetab.textwidget.event_generate('%3CTab%3E')%0A    assert filetab.textwidget.get('1.0', 'end - 1 char') == '''%5C%0Afoo%0A    bar%0A    biz%0Abaz'''%0A    assert list(map(str, filetab.textwidget.tag_ranges('sel'))) == %5B'2.0', '4.0'%5D%0A%0A    # shift-tab is platform specific, see utils.bind_tab_key%0A    %5Bshift_tab%5D = %5B%0A        key for key in filetab.textwidget.bind()%0A        if key.endswith('Tab%3E') and key != '%3CKey-Tab%3E'%0A    %5D%0A    filetab.textwidget.event_generate(shift_tab)%0A    assert filetab.textwidget.get('1.0', 'end - 1 char') == '''%5C%0Afoo%0Abar%0Abiz%0Abaz'''%0A    assert list(map(str, filetab.textwidget.tag_ranges('sel'))) == %5B'2.0', '4.0'%5D%0A

add indent_block plugin tests