mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.0601: too much indent
Problem: Too much indent. Solution: Return out early from a funtion. (Yegappan Lakshmanan, close #11238)
This commit is contained in:
committed by
Bram Moolenaar
parent
d324742292
commit
368aa69088
105
src/beval.c
105
src/beval.c
@@ -39,16 +39,19 @@ find_word_under_cursor(
|
||||
|
||||
*textp = NULL;
|
||||
wp = mouse_find_win(&row, &col, FAIL_POPUP);
|
||||
if (wp != NULL && row >= 0 && row < wp->w_height && col < wp->w_width)
|
||||
{
|
||||
if (wp == NULL || row < 0 || row >= wp->w_height || col >= wp->w_width)
|
||||
return FAIL;
|
||||
|
||||
// Found a window and the cursor is in the text. Now find the line
|
||||
// number.
|
||||
if (!mouse_comp_pos(wp, &row, &col, &lnum, NULL))
|
||||
{
|
||||
if (mouse_comp_pos(wp, &row, &col, &lnum, NULL))
|
||||
return FAIL; // position is below the last line
|
||||
|
||||
// Not past end of the file.
|
||||
lbuf = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
||||
if (col <= win_linetabsize(wp, lnum, lbuf, (colnr_T)MAXCOL))
|
||||
{
|
||||
if (col > win_linetabsize(wp, lnum, lbuf, (colnr_T)MAXCOL))
|
||||
return FAIL; // past end of line
|
||||
|
||||
// Not past end of line.
|
||||
if (getword)
|
||||
{
|
||||
@@ -122,12 +125,9 @@ find_word_under_cursor(
|
||||
*colp = col;
|
||||
if (startcolp != NULL)
|
||||
*startcolp = scol;
|
||||
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_BEVAL) || defined(PROTO)
|
||||
@@ -220,45 +220,26 @@ can_use_beval(void)
|
||||
) && msg_scrolled == 0;
|
||||
}
|
||||
|
||||
# ifdef FEAT_EVAL
|
||||
/*
|
||||
* Common code, invoked when the mouse is resting for a moment.
|
||||
* Evaluate the expression 'bexpr' and set the text in the balloon 'beval'.
|
||||
*/
|
||||
void
|
||||
general_beval_cb(BalloonEval *beval, int state UNUSED)
|
||||
static void
|
||||
bexpr_eval(
|
||||
BalloonEval *beval,
|
||||
char_u *bexpr,
|
||||
win_T *wp,
|
||||
linenr_T lnum,
|
||||
int col,
|
||||
char_u *text)
|
||||
{
|
||||
#ifdef FEAT_EVAL
|
||||
win_T *wp;
|
||||
int col;
|
||||
int use_sandbox;
|
||||
linenr_T lnum;
|
||||
char_u *text;
|
||||
static char_u *result = NULL;
|
||||
long winnr = 0;
|
||||
char_u *bexpr;
|
||||
buf_T *save_curbuf;
|
||||
size_t len;
|
||||
win_T *cw;
|
||||
#endif
|
||||
static int recursive = FALSE;
|
||||
long winnr = 0;
|
||||
buf_T *save_curbuf;
|
||||
int use_sandbox;
|
||||
static char_u *result = NULL;
|
||||
size_t len;
|
||||
|
||||
// Don't do anything when 'ballooneval' is off, messages scrolled the
|
||||
// windows up or we have no beval area.
|
||||
if (!can_use_beval() || beval == NULL)
|
||||
return;
|
||||
|
||||
// Don't do this recursively. Happens when the expression evaluation
|
||||
// takes a long time and invokes something that checks for CTRL-C typed.
|
||||
if (recursive)
|
||||
return;
|
||||
recursive = TRUE;
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
|
||||
{
|
||||
bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
|
||||
: wp->w_buffer->b_p_bexpr;
|
||||
if (*bexpr != NUL)
|
||||
{
|
||||
sctx_T save_sctx = current_sctx;
|
||||
|
||||
// Convert window pointer to number.
|
||||
@@ -322,7 +303,43 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
|
||||
// that requires a screen update.
|
||||
if (must_redraw)
|
||||
redraw_after_callback(FALSE, FALSE);
|
||||
}
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Common code, invoked when the mouse is resting for a moment.
|
||||
*/
|
||||
void
|
||||
general_beval_cb(BalloonEval *beval, int state UNUSED)
|
||||
{
|
||||
#ifdef FEAT_EVAL
|
||||
win_T *wp;
|
||||
int col;
|
||||
linenr_T lnum;
|
||||
char_u *text;
|
||||
char_u *bexpr;
|
||||
#endif
|
||||
static int recursive = FALSE;
|
||||
|
||||
// Don't do anything when 'ballooneval' is off, messages scrolled the
|
||||
// windows up or we have no beval area.
|
||||
if (!can_use_beval() || beval == NULL)
|
||||
return;
|
||||
|
||||
// Don't do this recursively. Happens when the expression evaluation
|
||||
// takes a long time and invokes something that checks for CTRL-C typed.
|
||||
if (recursive)
|
||||
return;
|
||||
recursive = TRUE;
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
|
||||
{
|
||||
bexpr = (*wp->w_buffer->b_p_bexpr == NUL) ? p_bexpr
|
||||
: wp->w_buffer->b_p_bexpr;
|
||||
if (*bexpr != NUL)
|
||||
{
|
||||
bexpr_eval(beval, bexpr, wp, lnum, col, text);
|
||||
recursive = FALSE;
|
||||
return;
|
||||
}
|
||||
|
76
src/blob.c
76
src/blob.c
@@ -60,18 +60,20 @@ rettv_blob_set(typval_T *rettv, blob_T *b)
|
||||
int
|
||||
blob_copy(blob_T *from, typval_T *to)
|
||||
{
|
||||
int ret = OK;
|
||||
int len;
|
||||
|
||||
to->v_type = VAR_BLOB;
|
||||
to->v_lock = 0;
|
||||
if (from == NULL)
|
||||
to->vval.v_blob = NULL;
|
||||
else if (rettv_blob_alloc(to) == FAIL)
|
||||
ret = FAIL;
|
||||
else
|
||||
{
|
||||
int len = from->bv_ga.ga_len;
|
||||
to->vval.v_blob = NULL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (rettv_blob_alloc(to) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
len = from->bv_ga.ga_len;
|
||||
if (len > 0)
|
||||
{
|
||||
to->vval.v_blob->bv_ga.ga_data =
|
||||
@@ -81,8 +83,8 @@ blob_copy(blob_T *from, typval_T *to)
|
||||
}
|
||||
to->vval.v_blob->bv_ga.ga_len = len;
|
||||
to->vval.v_blob->bv_ga.ga_maxlen = len;
|
||||
}
|
||||
return ret;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -280,21 +282,19 @@ failed:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
blob_slice_or_index(
|
||||
/*
|
||||
* Returns a slice of 'blob' from index 'n1' to 'n2' in 'rettv'. The length of
|
||||
* the blob is 'len'. Returns an empty blob if the indexes are out of range.
|
||||
*/
|
||||
static int
|
||||
blob_slice(
|
||||
blob_T *blob,
|
||||
int is_range,
|
||||
long len,
|
||||
varnumber_T n1,
|
||||
varnumber_T n2,
|
||||
int exclusive,
|
||||
typval_T *rettv)
|
||||
{
|
||||
long len = blob_len(blob);
|
||||
|
||||
if (is_range)
|
||||
{
|
||||
// The resulting variable is a sub-blob. If the indexes
|
||||
// are out of range the result is empty.
|
||||
if (n1 < 0)
|
||||
{
|
||||
n1 = len + n1;
|
||||
@@ -333,16 +333,28 @@ blob_slice_or_index(
|
||||
rettv_blob_set(rettv, new_blob);
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
else
|
||||
|
||||
/*
|
||||
* Return the byte value in 'blob' at index 'idx' in 'rettv'. If the index is
|
||||
* too big or negative that is an error. The length of the blob is 'len'.
|
||||
*/
|
||||
static int
|
||||
blob_index(
|
||||
blob_T *blob,
|
||||
int len,
|
||||
varnumber_T idx,
|
||||
typval_T *rettv)
|
||||
{
|
||||
// The resulting variable is a byte value.
|
||||
// If the index is too big or negative that is an error.
|
||||
if (n1 < 0)
|
||||
n1 = len + n1;
|
||||
if (n1 < len && n1 >= 0)
|
||||
if (idx < 0)
|
||||
idx = len + idx;
|
||||
if (idx < len && idx >= 0)
|
||||
{
|
||||
int v = blob_get(blob, n1);
|
||||
int v = blob_get(blob, idx);
|
||||
|
||||
clear_tv(rettv);
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
@@ -350,10 +362,28 @@ blob_slice_or_index(
|
||||
}
|
||||
else
|
||||
{
|
||||
semsg(_(e_blob_index_out_of_range_nr), n1);
|
||||
semsg(_(e_blob_index_out_of_range_nr), idx);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int
|
||||
blob_slice_or_index(
|
||||
blob_T *blob,
|
||||
int is_range,
|
||||
varnumber_T n1,
|
||||
varnumber_T n2,
|
||||
int exclusive,
|
||||
typval_T *rettv)
|
||||
{
|
||||
long len = blob_len(blob);
|
||||
|
||||
if (is_range)
|
||||
return blob_slice(blob, len, n1, n2, exclusive, rettv);
|
||||
else
|
||||
return blob_index(blob, len, n1, rettv);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@@ -699,6 +699,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
601,
|
||||
/**/
|
||||
600,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user