mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
* fix backspace at paragraph end. The inline completion should stay on screen.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23152 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b7782d1973
commit
ab8a1b0e70
@ -154,7 +154,8 @@ private:
|
||||
|
||||
|
||||
GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
|
||||
: QCompleter(parent), gui_(gui), updateLock_(0)
|
||||
: QCompleter(parent), gui_(gui), updateLock_(0),
|
||||
inlineVisible_(false)
|
||||
{
|
||||
// Setup the completion popup
|
||||
setModel(new GuiCompletionModel(this, 0));
|
||||
@ -233,7 +234,13 @@ bool GuiCompleter::popupVisible() const
|
||||
|
||||
bool GuiCompleter::inlineVisible() const
|
||||
{
|
||||
return !gui_->bufferView().inlineCompletionPos().empty();
|
||||
// In fact using BufferView::inlineCompletionPos.empty() should be
|
||||
// here. But unfortunately this information is not good enough
|
||||
// because destructive operations like backspace might invalidate
|
||||
// inlineCompletionPos. But then the completion should stay visible
|
||||
// (i.e. reshown on the next update). Hence be keep this information
|
||||
// in the inlineVisible_ variable.
|
||||
return inlineVisible_;
|
||||
}
|
||||
|
||||
|
||||
@ -265,8 +272,10 @@ void GuiCompleter::updateVisibility(Cursor & cur, bool start, bool keep, bool cu
|
||||
inline_timer_.stop();
|
||||
|
||||
// hide old inline completion
|
||||
if (inlineVisible())
|
||||
if (inlineVisible()) {
|
||||
gui_->bufferView().setInlineCompletion(cur, DocIterator(), docstring());
|
||||
inlineVisible_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
// we inserted something and are in a possible popup state?
|
||||
@ -352,6 +361,7 @@ void GuiCompleter::updateInline(Cursor & cur, QString const & completion)
|
||||
// set inline completion at cursor position
|
||||
size_t uniqueTo = max(longestUniqueCompletion().size(), prefix.size());
|
||||
gui_->bufferView().setInlineCompletion(cur, cur, postfix, uniqueTo - prefix.size());
|
||||
inlineVisible_ = true;
|
||||
}
|
||||
|
||||
|
||||
@ -523,7 +533,11 @@ void GuiCompleter::tab()
|
||||
if (completion.size() <= prefix.size()) {
|
||||
// finalize completion
|
||||
cur.inset().insertCompletion(cur, docstring(), true);
|
||||
|
||||
// hide popup and inline completion
|
||||
popup()->hide();
|
||||
gui_->bufferView().setInlineCompletion(cur, DocIterator(), docstring());
|
||||
inlineVisible_ = false;
|
||||
updateVisibility(false, false);
|
||||
return;
|
||||
}
|
||||
|
@ -109,6 +109,10 @@ private:
|
||||
QString last_selection_;
|
||||
/// lock to stop updates of the inline completion
|
||||
int updateLock_;
|
||||
/// the BufferView::inlineCursorPos might be reset by destructive
|
||||
/// operations like backspace. Hence, we have to keep this flag
|
||||
/// in addition to know whether the popup is to be kept visible.
|
||||
bool inlineVisible_;
|
||||
}; // GuiCompleter
|
||||
|
||||
} // namespace frontend
|
||||
|
Loading…
Reference in New Issue
Block a user