mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-30 07:04:32 +03:00
Context: do not store buffer, ask editor for it
This commit is contained in:
parent
9e3323bf68
commit
99eaa259e6
@ -12,19 +12,19 @@ struct Context
|
|||||||
{
|
{
|
||||||
Context() {}
|
Context() {}
|
||||||
Context(Editor& editor)
|
Context(Editor& editor)
|
||||||
: m_editor(&editor), m_buffer(&editor.buffer()) {}
|
: m_editor(&editor) {}
|
||||||
|
|
||||||
// to allow func(Context(Editor(...)))
|
// to allow func(Context(Editor(...)))
|
||||||
Context(Editor&& editor)
|
Context(Editor&& editor)
|
||||||
: m_editor(&editor), m_buffer(&editor.buffer()) {}
|
: m_editor(&editor) {}
|
||||||
|
|
||||||
Buffer& buffer() const
|
Buffer& buffer() const
|
||||||
{
|
{
|
||||||
if (not has_buffer())
|
if (not has_buffer())
|
||||||
throw runtime_error("no buffer in context");
|
throw runtime_error("no buffer in context");
|
||||||
return *m_buffer;
|
return m_editor->buffer();
|
||||||
}
|
}
|
||||||
bool has_buffer() const { return m_buffer; }
|
bool has_buffer() const { return m_editor; }
|
||||||
|
|
||||||
Editor& editor() const
|
Editor& editor() const
|
||||||
{
|
{
|
||||||
@ -56,8 +56,6 @@ struct Context
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
safe_ptr<Editor> m_editor;
|
safe_ptr<Editor> m_editor;
|
||||||
safe_ptr<Buffer> m_buffer;
|
|
||||||
|
|
||||||
int m_numeric_param = 0;
|
int m_numeric_param = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user