A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/d11bbacf0ffa45096364195bda4739984d25121e below:

do not change reg_prev_sub when previewing · neovim/neovim@d11bbac · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+84

-5

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+84

-5

lines changed Original file line number Diff line number Diff line change

@@ -3629,8 +3629,14 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle

3629 3629

// We do it here once to avoid it to be replaced over and over again.

3630 3630

// But don't do it when it starts with "\=", then it's an expression.

3631 3631

assert(sub != NULL);

3632 + 3633 +

bool sub_needs_free = false;

3632 3634

if (!(sub[0] == '\\' && sub[1] == '=')) {

3635 +

char_u *source = sub;

3633 3636

sub = regtilde(sub, p_magic);

3637 +

// When previewing, the new pattern allocated by regtilde() needs to be freed

3638 +

// in this function because it will not be used or freed by regtilde() later.

3639 +

sub_needs_free = preview && sub != source;

3634 3640

}

3635 3641 3636 3642

// Check for a match on each line.

@@ -4425,6 +4431,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle

4425 4431 4426 4432

kv_destroy(preview_lines.subresults);

4427 4433 4434 +

if (sub_needs_free) {

4435 +

xfree(sub);

4436 +

}

4437 + 4428 4438

return preview_buf;

4429 4439

#undef ADJUST_SUB_FIRSTLNUM

4430 4440

#undef PUSH_PREVIEW_LINES

Original file line number Diff line number Diff line change

@@ -6538,11 +6538,16 @@ char_u *regtilde(char_u *source, int magic)

6538 6538

}

6539 6539

}

6540 6540 6541 -

xfree(reg_prev_sub);

6542 -

if (newsub != source) /* newsub was allocated, just keep it */

6543 -

reg_prev_sub = newsub;

6544 -

else /* no ~ found, need to save newsub */

6545 -

reg_prev_sub = vim_strsave(newsub);

6541 +

// Only change reg_prev_sub when not previewing.

6542 +

if (!(State & CMDPREVIEW)) {

6543 +

xfree(reg_prev_sub);

6544 +

if (newsub != source) { // newsub was allocated, just keep it

6545 +

reg_prev_sub = newsub;

6546 +

} else { // no ~ found, need to save newsub

6547 +

reg_prev_sub = vim_strsave(newsub);

6548 +

}

6549 +

}

6550 + 6546 6551

return newsub;

6547 6552

}

6548 6553 Original file line number Diff line number Diff line change

@@ -293,6 +293,70 @@ describe(":substitute, 'inccommand' preserves", function()

293 293

end)

294 294

end

295 295 296 +

for _, case in ipairs({'', 'split', 'nosplit'}) do

297 +

it('previous substitute string ~ (inccommand='..case..') #12109', function()

298 +

local screen = Screen.new(30,10)

299 +

common_setup(screen, case, default_text)

300 + 301 +

feed(':%s/Inc/SUB<CR>')

302 +

expect([[

303 +

SUB substitution on

304 +

two lines

305 +

]])

306 + 307 +

feed(':%s/line/')

308 +

poke_eventloop()

309 +

feed('~')

310 +

poke_eventloop()

311 +

feed('<CR>')

312 +

expect([[

313 +

SUB substitution on

314 +

two SUBs

315 +

]])

316 + 317 +

feed(':%s/sti/')

318 +

poke_eventloop()

319 +

feed('~')

320 +

poke_eventloop()

321 +

feed('B')

322 +

poke_eventloop()

323 +

feed('<CR>')

324 +

expect([[

325 +

SUB subSUBBtution on

326 +

two SUBs

327 +

]])

328 + 329 +

feed(':%s/ion/NEW<CR>')

330 +

expect([[

331 +

SUB subSUBBtutNEW on

332 +

two SUBs

333 +

]])

334 + 335 +

feed(':%s/two/')

336 +

poke_eventloop()

337 +

feed('N')

338 +

poke_eventloop()

339 +

feed('~')

340 +

poke_eventloop()

341 +

feed('<CR>')

342 +

expect([[

343 +

SUB subSUBBtutNEW on

344 +

NNEW SUBs

345 +

]])

346 + 347 +

feed(':%s/bS/')

348 +

poke_eventloop()

349 +

feed('~')

350 +

poke_eventloop()

351 +

feed('W')

352 +

poke_eventloop()

353 +

feed('<CR>')

354 +

expect([[

355 +

SUB suNNEWWUBBtutNEW on

356 +

NNEW SUBs

357 +

]])

358 +

end)

359 +

end

296 360

end)

297 361 298 362

describe(":substitute, 'inccommand' preserves undo", function()

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4