mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
revert: "vim-patch:9.1.0055: formatting long lines is slow"
Revert "vim-patch:9.1.0055: formatting long lines is slow (#27199)"
This reverts commit 89a9745a1a
.
Fix #28197
This commit is contained in:
@@ -105,14 +105,9 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
|||||||
colnr_T col;
|
colnr_T col;
|
||||||
bool did_do_comment = false;
|
bool did_do_comment = false;
|
||||||
|
|
||||||
// Cursor is currently at the end of line. No need to format
|
colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor());
|
||||||
// if line length is less than textwidth (8 * textwidth for
|
if (virtcol <= (colnr_T)textwidth) {
|
||||||
// utf safety)
|
break;
|
||||||
if (curwin->w_cursor.col < 8 * textwidth) {
|
|
||||||
colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor());
|
|
||||||
if (virtcol <= (colnr_T)textwidth) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_leader) {
|
if (no_leader) {
|
||||||
@@ -160,16 +155,9 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
|||||||
coladvance(curwin, (colnr_T)textwidth);
|
coladvance(curwin, (colnr_T)textwidth);
|
||||||
wantcol = curwin->w_cursor.col;
|
wantcol = curwin->w_cursor.col;
|
||||||
|
|
||||||
// If startcol is large (a long line), formatting takes too much
|
curwin->w_cursor.col = startcol;
|
||||||
// time. The algorithm is O(n^2), it walks from the end of the
|
|
||||||
// line to textwidth border every time for each line break.
|
|
||||||
//
|
|
||||||
// Ceil to 8 * textwidth to optimize.
|
|
||||||
curwin->w_cursor.col = startcol < 8 * textwidth ? startcol : 8 * textwidth;
|
|
||||||
|
|
||||||
foundcol = 0;
|
foundcol = 0;
|
||||||
int skip_pos = 0;
|
int skip_pos = 0;
|
||||||
bool first_pass = true;
|
|
||||||
|
|
||||||
// Find position to break at.
|
// Find position to break at.
|
||||||
// Stop at first entered white when 'formatoptions' has 'v'
|
// Stop at first entered white when 'formatoptions' has 'v'
|
||||||
@@ -177,9 +165,8 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
|||||||
|| (flags & INSCHAR_FORMAT)
|
|| (flags & INSCHAR_FORMAT)
|
||||||
|| curwin->w_cursor.lnum != Insstart.lnum
|
|| curwin->w_cursor.lnum != Insstart.lnum
|
||||||
|| curwin->w_cursor.col >= Insstart.col) {
|
|| curwin->w_cursor.col >= Insstart.col) {
|
||||||
if (first_pass && c != NUL) {
|
if (curwin->w_cursor.col == startcol && c != NUL) {
|
||||||
cc = c;
|
cc = c;
|
||||||
first_pass = false;
|
|
||||||
} else {
|
} else {
|
||||||
cc = gchar_cursor();
|
cc = gchar_cursor();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user