• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

antonvw / wex / 13090099185

01 Feb 2025 03:47PM UTC coverage: 58.705%. Remained the same
13090099185

push

github

web-flow
clang-tidy fixes (#829)

16542 of 31036 branches covered (53.3%)

Branch coverage included in aggregate %.

13323 of 19837 relevant lines covered (67.16%)

1218.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.18
/src/ex/vi/command-parse.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      command-parse.cpp
3
// Purpose:   Implementation of class wex::vi::parse_command
4
// Author:    Anton van Wezenbeek
5
// Copyright: (c) 2020-2025 Anton van Wezenbeek
6
////////////////////////////////////////////////////////////////////////////////
7

8
#include <wex/ex/macros.h>
9
#include <wex/syntax/stc.h>
10
#include <wex/vi/vi.h>
11

12
#include "vim.h"
13

14
bool wex::vi::parse_command(std::string& command)
1,211✔
15
{
16
  if (const auto& it = get_macros().get_keys_map().find(command.front());
1,211✔
17
      it != get_macros().get_keys_map().end())
1,211✔
18
  {
19
    command = it->second;
1✔
20
  }
21

22
  if (
1,211✔
23
    m_command.type() != ex_command::type_t::FIND &&
2,422!
24
    m_command.type() != ex_command::type_t::FIND_MARGIN)
1,211!
25
  {
26
    m_count = 1;
1,211✔
27
  }
28

29
  // if this is a register, wait for next char for register name
30
  if (command.front() == '"')
1,211✔
31
  {
32
    if (command.size() < 2)
1!
33
    {
34
      return false;
×
35
    }
36
    set_register(command[1]);
1✔
37
    command.erase(0, 2);
1✔
38
    return true;
1✔
39
  }
40

41
  if (command.front() == ':')
1,210✔
42
  {
43
    return ex::command(command);
419✔
44
  }
45

46
  filter_count(command);
791✔
47

48
  if (command.empty())
791!
49
  {
50
    return false;
×
51
  }
52

53
  return parse_command_handle(command);
791✔
54
}
55

56
bool wex::vi::parse_command_handle(std::string& command)
791✔
57
{
58
  const motion_t motion      = get_motion(command);
791✔
59
  bool           check_other = true;
791✔
60

61
  if (command.size() == 1)
791✔
62
  {
63
    if (parse_command_handle_single(motion, command, check_other))
456✔
64
    {
65
      return true;
1✔
66
    }
67
  }
68
  else if (
335✔
69
    other_command(command) ||
598✔
70
    parse_command_motion(motion, command, check_other))
263✔
71
  {
72
    return true;
78✔
73
  }
74

75
  if (
712✔
76
    check_other && !motion_command(motion, command) && !other_command(command))
712✔
77
  {
78
    return false;
17✔
79
  }
80

81
  set_register(0);
695✔
82

83
  if (!command.empty())
695✔
84
  {
85
    if (m_mode.is_insert())
41✔
86
    {
87
      return insert_mode(command);
19✔
88
    }
89
    if (command != m_command_string)
22!
90
    {
91
      return parse_command(command);
22✔
92
    }
93

94
    return false;
×
95
  }
96

97
  return true;
654✔
98
}
99

100
bool wex::vi::parse_command_handle_single(
456✔
101
  motion_t     motion,
102
  std::string& command,
103
  bool&        check_other)
104
{
105
  if (
456✔
106
    (m_mode.is_visual() || command == "d") &&
296✔
107
    !get_stc()->get_selected_text().empty() &&
792!
108
    (motion == motion_t::CHANGE || motion == motion_t::DEL ||
40✔
109
     motion == motion_t::YANK))
110
  {
111
    if (motion == motion_t::CHANGE)
4✔
112
    {
113
      std::string s("i");
1✔
114
      m_mode.transition(s);
1✔
115
      command.erase(0, 1);
1✔
116
      return true;
1✔
117
    }
1✔
118

119
    command.erase(0, 1);
3✔
120
    m_mode_yank = m_mode.get();
3✔
121
    m_mode.escape();
3✔
122
  }
123
  else if (m_mode.transition(command))
452✔
124
  {
125
    check_other = false;
210✔
126
  }
127
  else
128
  {
129
    m_insert_command.clear();
242✔
130
  }
131

132
  return false;
455✔
133
}
134

135
bool wex::vi::parse_command_motion(
263✔
136
  motion_t     motion,
137
  std::string& command,
138
  bool&        check_other)
139
{
140
  if (wex::vim vim(this, command, motion); vim.is_special())
263✔
141
  {
142
    if (vim.special())
6!
143
    {
144
      return true;
6✔
145
    }
146
  }
147
  else
148
  {
149
    switch (motion)
257✔
150
    {
151
      case motion_t::CHANGE:
58✔
152
        m_mode.transition(command);
58✔
153
        break;
58✔
154

155
      case motion_t::DEL:
118✔
156
      case motion_t::YANK:
157
        command.erase(0, 1);
118✔
158
        break;
118✔
159

160
      case motion_t::NAVIGATE:
74✔
161
        if (m_mode.transition(command))
74✔
162
        {
163
          check_other = false;
19✔
164
        }
165
        else
166
        {
167
          m_insert_command.clear();
55✔
168
        }
169
        break;
74✔
170

171
      default:
7✔
172
        // do nothing
173
        break;
7✔
174
    }
175
  }
176

177
  return false;
257✔
178
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc