Support delete from :{quick,book}mark-load.
Pressing ctrl-d in the completion menu for :quickmark-load/:bookmark-load will now delete the selected quickmark/bookmark. Resolves #2840.
This commit is contained in:
parent
8f63bb1edc
commit
1ab7bb83cc
@ -60,17 +60,33 @@ def helptopic():
|
||||
|
||||
def quickmark():
|
||||
"""A CompletionModel filled with all quickmarks."""
|
||||
def delete(data):
|
||||
"""Delete a quickmark from the completion menu."""
|
||||
name = data[0]
|
||||
quickmark_manager = objreg.get('quickmark-manager')
|
||||
log.completion.debug('Deleting quickmark {}'.format(name))
|
||||
quickmark_manager.delete(name)
|
||||
|
||||
model = completionmodel.CompletionModel(column_widths=(30, 70, 0))
|
||||
marks = objreg.get('quickmark-manager').marks.items()
|
||||
model.add_category(listcategory.ListCategory('Quickmarks', marks))
|
||||
model.add_category(listcategory.ListCategory('Quickmarks', marks,
|
||||
delete_func=delete))
|
||||
return model
|
||||
|
||||
|
||||
def bookmark():
|
||||
"""A CompletionModel filled with all bookmarks."""
|
||||
def delete(data):
|
||||
"""Delete a bookmark from the completion menu."""
|
||||
urlstr = data[0]
|
||||
log.completion.debug('Deleting bookmark {}'.format(urlstr))
|
||||
bookmark_manager = objreg.get('bookmark-manager')
|
||||
bookmark_manager.delete(urlstr)
|
||||
|
||||
model = completionmodel.CompletionModel(column_widths=(30, 70, 0))
|
||||
marks = objreg.get('bookmark-manager').marks.items()
|
||||
model.add_category(listcategory.ListCategory('Bookmarks', marks))
|
||||
model.add_category(listcategory.ListCategory('Bookmarks', marks,
|
||||
delete_func=delete))
|
||||
return model
|
||||
|
||||
|
||||
|
@ -252,6 +252,27 @@ def test_quickmark_completion(qtmodeltester, quickmarks):
|
||||
})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('row, removed', [
|
||||
(0, 'aw'),
|
||||
(1, 'ddg'),
|
||||
(2, 'wiki'),
|
||||
])
|
||||
def test_quickmark_completion_delete(qtmodeltester, quickmarks, row, removed):
|
||||
"""Test deleting a quickmark from the quickmark completion model."""
|
||||
model = miscmodels.quickmark()
|
||||
model.set_pattern('')
|
||||
qtmodeltester.data_display_may_return_none = True
|
||||
qtmodeltester.check(model)
|
||||
|
||||
parent = model.index(0, 0)
|
||||
idx = model.index(row, 0, parent)
|
||||
|
||||
before = set(quickmarks.marks.keys())
|
||||
model.delete_cur_item(idx)
|
||||
after = set(quickmarks.marks.keys())
|
||||
assert before.difference(after) == {removed}
|
||||
|
||||
|
||||
def test_bookmark_completion(qtmodeltester, bookmarks):
|
||||
"""Test the results of bookmark completion."""
|
||||
model = miscmodels.bookmark()
|
||||
@ -268,6 +289,27 @@ def test_bookmark_completion(qtmodeltester, bookmarks):
|
||||
})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('row, removed', [
|
||||
(0, 'http://qutebrowser.org'),
|
||||
(1, 'https://github.com'),
|
||||
(2, 'https://python.org'),
|
||||
])
|
||||
def test_bookmark_completion_delete(qtmodeltester, bookmarks, row, removed):
|
||||
"""Test deleting a quickmark from the quickmark completion model."""
|
||||
model = miscmodels.bookmark()
|
||||
model.set_pattern('')
|
||||
qtmodeltester.data_display_may_return_none = True
|
||||
qtmodeltester.check(model)
|
||||
|
||||
parent = model.index(0, 0)
|
||||
idx = model.index(row, 0, parent)
|
||||
|
||||
before = set(bookmarks.marks.keys())
|
||||
model.delete_cur_item(idx)
|
||||
after = set(bookmarks.marks.keys())
|
||||
assert before.difference(after) == {removed}
|
||||
|
||||
|
||||
def test_url_completion(qtmodeltester, web_history_populated,
|
||||
quickmarks, bookmarks):
|
||||
"""Test the results of url completion.
|
||||
|
Loading…
Reference in New Issue
Block a user