Skip to content

Commit

Permalink
How do I make this compile?
Browse files Browse the repository at this point in the history
```
normal.cc:2108:78: error: no matching constructor for initialization of 'const HashMap<Kakoune::Key, Kakoune::NormalCmd,
      MemoryDomain::Undefined, KeymapBackend>'
static const HashMap<Key, NormalCmd, MemoryDomain::Undefined, KeymapBackend> keymap = {
                                                                             ^        ~
./hash_map.hh:171:15: note: candidate constructor not viable: requires single argument 'val', but 159 arguments were provided
    constexpr HashMap(std::initializer_list<Item> val) : m_items(val), m_index(val.size())
              ^
./hash_map.hh:164:8: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 159 were
      provided
struct HashMap
       ^
./hash_map.hh:164:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 159 were
      provided
./hash_map.hh:169:15: note: candidate constructor not viable: requires 0 arguments, but 159 were provided
    constexpr HashMap() = default;
              ^
1 error generated.
```
  • Loading branch information
dpc committed Nov 23, 2018
1 parent ec6b88b commit b8d3f08
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
15 changes: 15 additions & 0 deletions src/context.hh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ public:
m_jump_list.push(selections());
}

void enter_or_keep_line_editing() {
m_keep_line_mode = true;
}

bool is_line_editing() {
return m_line_mode;
}

void post_key_logic() {
m_line_mode = m_keep_line_mode;
m_keep_line_mode = false;
}

template<typename Func>
void set_last_select(Func&& last_select) { m_last_select = std::forward<Func>(last_select); }

Expand All @@ -135,6 +148,8 @@ private:
void end_edition();
int m_edition_level = 0;
size_t m_edition_timestamp = 0;
bool m_line_mode = false;
bool m_keep_line_mode = false;

friend struct ScopedEdition;

Expand Down
2 changes: 2 additions & 0 deletions src/input_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ class Normal : public InputMode
context().hooks().run_hook(Hook::NormalKey, key_to_str(key), context());
if (enabled() and not transient) // The hook might have changed mode
m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context()));

context().post_key_logic();
}

DisplayLine mode_line() const override
Expand Down
19 changes: 13 additions & 6 deletions src/selectors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,17 @@ template Optional<Selection> select_word<WordType::Word>(const Context&, const S
template Optional<Selection> select_word<WordType::WORD>(const Context&, const Selection&, int, ObjectFlags);

Optional<Selection>
select_line(const Context& context, const Selection& selection)
select_line(Context& context, const Selection& selection)
{
auto& buffer = context.buffer();
auto line = selection.cursor().line;
// Next line if line fully selected
if (selection.anchor() <= BufferCoord{line, 0_byte} and
selection.cursor() == BufferCoord{line, buffer[line].length() - 1} and
line != buffer.line_count() - 1)
if (context.is_line_editing()) {
++line;
}

context.enter_or_keep_line_editing();

return target_eol({{line, 0_byte}, {line, buffer[line].length() - 1}});
}

Expand Down Expand Up @@ -809,8 +811,10 @@ select_argument(const Context& context, const Selection& selection,
}

Optional<Selection>
select_lines(const Context& context, const Selection& selection)
select_lines(Context& context, const Selection& selection)
{
context.enter_or_keep_line_editing();

auto& buffer = context.buffer();
BufferCoord anchor = selection.anchor();
BufferCoord cursor = selection.cursor();
Expand All @@ -824,14 +828,17 @@ select_lines(const Context& context, const Selection& selection)
}

Optional<Selection>
trim_partial_lines(const Context& context, const Selection& selection)
trim_partial_lines(Context& context, const Selection& selection)
{
auto& buffer = context.buffer();
BufferCoord anchor = selection.anchor();
BufferCoord cursor = selection.cursor();
BufferCoord& to_line_start = anchor <= cursor ? anchor : cursor;
BufferCoord& to_line_end = anchor <= cursor ? cursor : anchor;


context.enter_or_keep_line_editing();

if (to_line_start.column != 0)
to_line_start = to_line_start.line+1;
if (to_line_end.column != buffer[to_line_end.line].length()-1)
Expand Down
6 changes: 3 additions & 3 deletions src/selectors.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Optional<Selection>
select_to_previous_word(const Context& context, const Selection& selection);

Optional<Selection>
select_line(const Context& context, const Selection& selection);
select_line(Context& context, const Selection& selection);

template<bool forward>
Optional<Selection>
Expand Down Expand Up @@ -92,10 +92,10 @@ select_argument(const Context& context, const Selection& selection,
int level, ObjectFlags flags);

Optional<Selection>
select_lines(const Context& context, const Selection& selection);
select_lines(Context& context, const Selection& selection);

Optional<Selection>
trim_partial_lines(const Context& context, const Selection& selection);
trim_partial_lines(Context& context, const Selection& selection);

void select_buffer(SelectionList& selections);

Expand Down

0 comments on commit b8d3f08

Please sign in to comment.