Changeset View
Changeset View
Standalone View
Standalone View
src/vimode/commandrangeexpressionparser.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
110 | 110 | | |||
111 | QString position_string1 = rangeMatch.captured(1); | 111 | QString position_string1 = rangeMatch.captured(1); | ||
112 | QString position_string2 = rangeMatch.captured(4); | 112 | QString position_string2 = rangeMatch.captured(4); | ||
113 | int position1 = calculatePosition(position_string1); | 113 | int position1 = calculatePosition(position_string1); | ||
114 | int position2 = (position_string2.isEmpty()) ? position1 : calculatePosition(rangeMatch.captured(5)); | 114 | int position2 = (position_string2.isEmpty()) ? position1 : calculatePosition(rangeMatch.captured(5)); | ||
115 | 115 | | |||
116 | commandTmp.remove(RE_CmdRange()); | 116 | commandTmp.remove(RE_CmdRange()); | ||
117 | 117 | | |||
118 | // Vi indexes lines starting from 1; however, it does accept 0 as a valid line index | ||||
119 | // and treats it as 1 | ||||
120 | position1 = (position1 == 0) ? 1 : position1; | ||||
121 | position2 = (position2 == 0) ? 1 : position2; | ||||
122 | | ||||
118 | // special case: if the command is just a number with an optional +/- prefix, rewrite to "goto" | 123 | // special case: if the command is just a number with an optional +/- prefix, rewrite to "goto" | ||
119 | if (commandTmp.isEmpty()) { | 124 | if (commandTmp.isEmpty()) { | ||
120 | destTransformedCommand = QStringLiteral("goto %1").arg(position1); | 125 | destTransformedCommand = QStringLiteral("goto %1").arg(position1); | ||
121 | return KTextEditor::Range::invalid(); | 126 | return KTextEditor::Range::invalid(); | ||
122 | } else { | 127 | } else { | ||
123 | destTransformedCommand = commandTmp; | 128 | destTransformedCommand = commandTmp; | ||
124 | return KTextEditor::Range(KTextEditor::Range(position1 - 1, 0, position2 - 1, 0)); | 129 | return KTextEditor::Range(KTextEditor::Range(position1 - 1, 0, position2 - 1, 0)); | ||
125 | } | 130 | } | ||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |