Add g. command to go to the last buffer modification position
This commit is contained in:
parent
a387e7a4c6
commit
33de42610d
|
@ -245,6 +245,8 @@ Commands begining with g are used to goto certain position and or buffer:
|
|||
* _ga_: go to the previous (alternate) buffer
|
||||
* _gf_: open the file whose name is selected
|
||||
|
||||
* _g._: go to last buffer modifiction position
|
||||
|
||||
View commands
|
||||
-------------
|
||||
|
||||
|
|
|
@ -715,4 +715,11 @@ void Buffer::run_hook_in_own_context(const String& hook_name, const String& para
|
|||
m_hooks.run_hook(hook_name, param, hook_handler.context());
|
||||
}
|
||||
|
||||
BufferCoord Buffer::last_modification_coord() const
|
||||
{
|
||||
if (m_history.empty())
|
||||
return {};
|
||||
return m_history.back().back().coord;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -136,6 +136,8 @@ public:
|
|||
bool is_valid(BufferCoord c) const;
|
||||
bool is_end(BufferCoord c) const;
|
||||
|
||||
BufferCoord last_modification_coord() const;
|
||||
|
||||
BufferIterator begin() const;
|
||||
BufferIterator end() const;
|
||||
ByteCount byte_count() const;
|
||||
|
|
|
@ -315,6 +315,15 @@ void goto_commands(Context& context, int line)
|
|||
CommandManager::instance().execute("edit '" + path + "'", context);
|
||||
break;
|
||||
}
|
||||
case '.':
|
||||
{
|
||||
context.push_jump();
|
||||
auto pos = buffer.last_modification_coord();
|
||||
if (buffer[pos.line].length() == pos.column + 1)
|
||||
pos = BufferCoord{ pos.line+1, 0 };
|
||||
select_coord<mode>(buffer, pos, context.selections());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, "goto",
|
||||
"g,k: buffer top \n"
|
||||
|
@ -326,7 +335,8 @@ void goto_commands(Context& context, int line)
|
|||
"b: window bottom \n"
|
||||
"c: window center \n"
|
||||
"a: last buffer \n"
|
||||
"f: file \n");
|
||||
"f: file \n"
|
||||
".: last buffer change\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user