@@ -45,6 +45,10 @@ declare-option -hidden str jumpContents
45
45
# Selection description of the visible part of the buffer.
46
46
declare-option -hidden str jumpContentsRange
47
47
48
+ # A temporary storage for the selection description of the target word
49
+ # when executing a jump with `-add` switch.
50
+ declare-option -hidden str jumpAddSelectionDesc
51
+
48
52
# Grab window content and push it into respective options
49
53
define-command -hidden jumpSelectWindow %{
50
54
eval -draft %{
@@ -111,30 +115,12 @@ define-command -hidden jumpRemoveHighlighters %{
111
115
remove-highlighter window /jumpLabels
112
116
}
113
117
114
- # Record keypresses and execute the jump as soon as there's a matching label
115
- define-command -hidden jumpOnPromptChange %{
118
+ define-command -hidden jumpOnPromptChange -params 1 ..1 %{
116
119
evaluate-commands %sh{
117
- node -e "
118
- const jumpLabels = JSON.parse('$kak_opt_jumpLabelsPositions ')
119
- const targetLabel = jumpLabels.find(label => label.label === '$kak_text ')
120
- if (targetLabel === undefined) process.exit()
121
- console.log('execute-keys <esc>')
122
- console.log('select -display-column ' + targetLabel.selectionDescription)
123
- console.log('execute-keys <semicolon>he')
124
- "
125
- }
126
- }
127
-
128
- define-command -hidden jumpExtendOnPromptChange %{
129
- evaluate-commands %sh{
130
- node -e "
131
- const jumpLabels = JSON.parse('$kak_opt_jumpLabelsPositions ')
132
- const targetLabel = jumpLabels.find(label => label.label === '$kak_text ')
133
- if (targetLabel === undefined) process.exit()
134
- console.log('execute-keys <esc>')
135
- console.log('select -display-column ' + targetLabel.selectionDescription)
136
- if (targetLabel.jumpOrientationForward) console.log('execute-keys HE')
137
- "
120
+ # Environment variables to expose:
121
+ # $kak_text
122
+ # $kak_opt_jumpLabelsPositions
123
+ jumpMode=" $1 " node " $( dirname $kak_opt_jumpSourcePath ) /performJump.js"
138
124
}
139
125
}
140
126
@@ -146,19 +132,17 @@ define-command -hidden jumpOnPromptSubmit %{
146
132
echo -markup ' {Error}Jump label not found'
147
133
}
148
134
149
- define-command jumpJump \
150
- -params 0 \
151
- -docstring " Perform a labels-based jump within the visible part of the buffer" \
152
- %{
153
- jumpPrepareJump
154
- prompt ' Jump to: ' -on-change jumpOnPromptChange -on-abort jumpRemoveHighlighters jumpOnPromptSubmit
155
- }
135
+ define-command -params 0 ..1 -docstring "
136
+ jumpJump [<switches>]: perform a labels-based jump within the visible part of the buffer
137
+
138
+ Switches describe the way the jump will modify current selection (s).
139
+ -discard Default behavior. Discard existing selection (s) and select target word.
140
+ -add Keep existing selection (s) and add target word as a new selection .
141
+ -extend Extend current primary selection up to and including target word. See option `jumpAutoFlipOnExtend` for more details.
142
+ " jumpJump %{
156
143
157
- define-command jumpExtend \
158
- -params 0 \
159
- -docstring " Perform a labels-based jump within the visible part of the buffer, extending current selection" \
160
- %{
161
144
jumpPrepareJump
162
- prompt ' Extend to: ' -on-change jumpExtendOnPromptChange -on-abort jumpRemoveHighlighters jumpOnPromptSubmit
145
+ prompt ' Label: ' -on-change %{ jumpOnPromptChange %arg{1 } } -on-abort jumpRemoveHighlighters jumpOnPromptSubmit
146
+
163
147
}
164
148
0 commit comments