Mercurial > vim
comparison src/normal.c @ 31984:479c93ad4a3b v9.0.1324
patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Commit: https://github.com/vim/vim/commit/441a7a94482f704b66253b8d08130f27b6b13736
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Sat Feb 18 20:15:44 2023 +0000
patch 9.0.1324: "gj" and "gk" do not move correctly over a closed fold
Problem: "gj" and "gk" do not move correctly over a closed fold.
Solution: Use the same code as used for "j"/"k" to go to the next/previous
line. (Luuk van Baal, closes #12007)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Feb 2023 21:30:03 +0100 |
parents | d8fdafc4b390 |
children | 4545f58c8490 |
comparison
equal
deleted
inserted
replaced
31983:6e76bc357434 | 31984:479c93ad4a3b |
---|---|
2342 // which will get clipped to column 0. | 2342 // which will get clipped to column 0. |
2343 curwin->w_curswant -= width2; | 2343 curwin->w_curswant -= width2; |
2344 else | 2344 else |
2345 { | 2345 { |
2346 // to previous line | 2346 // to previous line |
2347 #ifdef FEAT_FOLDING | 2347 if (!cursor_up_inner(curwin, 1)) |
2348 // Move to the start of a closed fold. Don't do that when | |
2349 // 'foldopen' contains "all": it will open in a moment. | |
2350 if (!(fdo_flags & FDO_ALL)) | |
2351 (void)hasFolding(curwin->w_cursor.lnum, | |
2352 &curwin->w_cursor.lnum, NULL); | |
2353 #endif | |
2354 if (curwin->w_cursor.lnum == 1) | |
2355 { | 2348 { |
2356 retval = FAIL; | 2349 retval = FAIL; |
2357 break; | 2350 break; |
2358 } | 2351 } |
2359 --curwin->w_cursor.lnum; | |
2360 | |
2361 linelen = linetabsize_str(ml_get_curline()); | 2352 linelen = linetabsize_str(ml_get_curline()); |
2362 if (linelen > width1) | 2353 if (linelen > width1) |
2363 curwin->w_curswant += (((linelen - width1 - 1) / width2) | 2354 curwin->w_curswant += (((linelen - width1 - 1) / width2) |
2364 + 1) * width2; | 2355 + 1) * width2; |
2365 } | 2356 } |
2378 // move forward within line | 2369 // move forward within line |
2379 curwin->w_curswant += width2; | 2370 curwin->w_curswant += width2; |
2380 else | 2371 else |
2381 { | 2372 { |
2382 // to next line | 2373 // to next line |
2383 #ifdef FEAT_FOLDING | 2374 if (!cursor_down_inner(curwin, 1)) |
2384 // Move to the end of a closed fold. | |
2385 (void)hasFolding(curwin->w_cursor.lnum, NULL, | |
2386 &curwin->w_cursor.lnum); | |
2387 #endif | |
2388 if (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count) | |
2389 { | 2375 { |
2390 retval = FAIL; | 2376 retval = FAIL; |
2391 break; | 2377 break; |
2392 } | 2378 } |
2393 curwin->w_cursor.lnum++; | |
2394 curwin->w_curswant %= width2; | 2379 curwin->w_curswant %= width2; |
2395 // Check if the cursor has moved below the number display | 2380 // Check if the cursor has moved below the number display |
2396 // when width1 < width2 (with cpoptions+=n). Subtract width2 | 2381 // when width1 < width2 (with cpoptions+=n). Subtract width2 |
2397 // to get a negative value for w_curswant, which will get | 2382 // to get a negative value for w_curswant, which will get |
2398 // clipped to column 0. | 2383 // clipped to column 0. |