You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just missed the fact that getreg() also works and I don't need to hack
to use clip_convert_selection() and the mod on it. This is kind of...
odd, because clip_convert_selection() is essentially doing the same
thing as getreg() with *very* minor differences. You would hope that
would be consolidated and refactored into a single function, but of
course not.
Also cleaned up some comments to make it clear that evaluateExpression
probably would have worked except for the autocmd blocking part.
/// Extracts the text currently selected in visual mode, and return them in str/len.
1360
+
/// Extracts the text currently selected in visual mode, and returns it.
1361
1361
///
1362
-
/// @return the motion type (e.g. blockwise), or -1 for failure.
1363
-
static int extractSelectedText(char_u **str, long_u *len)
1362
+
/// @return the string representing the selected text, or NULL if failure.
1363
+
static char_u *extractSelectedText()
1364
1364
{
1365
1365
// Note: Most of the functionality in Vim that allows for extracting useful
1366
1366
// text from a selection are in the register & clipboard utility functions.
@@ -1372,7 +1372,7 @@ static int extractSelectedText(char_u **str, long_u *len)
1372
1372
1373
1373
if (!(VIsual_active && (State & MODE_NORMAL))) {
1374
1374
// This only works when we are in visual mode and have stuff to select.
1375
-
return -1;
1375
+
return NULL;
1376
1376
}
1377
1377
1378
1378
// Step 1: Find a register to yank the selection to. If we don't do this we
@@ -1423,9 +1423,8 @@ static int extractSelectedText(char_u **str, long_u *len)
1423
1423
ca.retval = CA_NO_ADJ_OP_END;
1424
1424
do_pending_operator(&ca, 0, TRUE);
1425
1425
1426
-
// Step 3: Convert the yank register to a single piece of useful text. This
1427
-
// will handle all the edge cases of different modes (e.g. blockwise, etc).
1428
-
const int convert_result = clip_convert_selection(str, len, NULL);
1426
+
// Step 3: Extract the text from the yank ('0') register.
1427
+
char_u *str = get_reg_contents(0, 0);
1429
1428
1430
1429
// Step 4: Clean up the yank register, and restore it back.
1431
1430
set_y_current(target_reg); // should not be necessary as it's done in do_pending_operator above (since regname was set to 0), but just to be safe and verbose in intention.
@@ -1447,7 +1446,7 @@ static int extractSelectedText(char_u **str, long_u *len)
1447
1446
1448
1447
unblock_autocmds();
1449
1448
1450
-
return convert_result;
1449
+
return str;
1451
1450
}
1452
1451
1453
1452
/// Extract the currently selected text (in visual mode) and send that to the
0 commit comments