mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
Merge pull request #3996 from justinmk/ctrlc
vim-patch:7.4.569, 7.4.573
This commit is contained in:
@@ -751,6 +751,8 @@ struct file_buffer {
|
|||||||
Terminal *terminal; // Terminal instance associated with the buffer
|
Terminal *terminal; // Terminal instance associated with the buffer
|
||||||
|
|
||||||
dict_T *additional_data; // Additional data from shada file if any.
|
dict_T *additional_data; // Additional data from shada file if any.
|
||||||
|
|
||||||
|
int b_mapped_ctrl_c; // modes where CTRL-C is mapped
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -2940,8 +2940,12 @@ do_map (
|
|||||||
if (!did_it) {
|
if (!did_it) {
|
||||||
retval = 2; /* no match */
|
retval = 2; /* no match */
|
||||||
} else if (*keys == Ctrl_C) {
|
} else if (*keys == Ctrl_C) {
|
||||||
/* If CTRL-C has been unmapped, reuse it for Interrupting. */
|
// If CTRL-C has been unmapped, reuse it for Interrupting.
|
||||||
mapped_ctrl_c = FALSE;
|
if (map_table == curbuf->b_maphash) {
|
||||||
|
curbuf->b_mapped_ctrl_c &= ~mode;
|
||||||
|
} else {
|
||||||
|
mapped_ctrl_c &= ~mode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
@@ -2966,9 +2970,14 @@ do_map (
|
|||||||
*/
|
*/
|
||||||
mp = xmalloc(sizeof(mapblock_T));
|
mp = xmalloc(sizeof(mapblock_T));
|
||||||
|
|
||||||
/* If CTRL-C has been mapped, don't always use it for Interrupting. */
|
// If CTRL-C has been mapped, don't always use it for Interrupting.
|
||||||
if (*keys == Ctrl_C)
|
if (*keys == Ctrl_C) {
|
||||||
mapped_ctrl_c = TRUE;
|
if (map_table == curbuf->b_maphash) {
|
||||||
|
curbuf->b_mapped_ctrl_c |= mode;
|
||||||
|
} else {
|
||||||
|
mapped_ctrl_c |= mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mp->m_keys = vim_strsave(keys);
|
mp->m_keys = vim_strsave(keys);
|
||||||
mp->m_str = vim_strsave(rhs);
|
mp->m_str = vim_strsave(rhs);
|
||||||
|
@@ -887,7 +887,7 @@ EXTERN int ctrl_x_mode INIT(= 0); /* Which Ctrl-X mode are we in? */
|
|||||||
|
|
||||||
EXTERN int no_abbr INIT(= TRUE); /* TRUE when no abbreviations loaded */
|
EXTERN int no_abbr INIT(= TRUE); /* TRUE when no abbreviations loaded */
|
||||||
|
|
||||||
EXTERN int mapped_ctrl_c INIT(= FALSE); /* CTRL-C is mapped */
|
EXTERN int mapped_ctrl_c INIT(= 0); // Modes where CTRL-C is mapped.
|
||||||
|
|
||||||
EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
|
EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
|
||||||
|
|
||||||
|
@@ -2352,7 +2352,7 @@ int get_keystroke(void)
|
|||||||
int save_mapped_ctrl_c = mapped_ctrl_c;
|
int save_mapped_ctrl_c = mapped_ctrl_c;
|
||||||
int waited = 0;
|
int waited = 0;
|
||||||
|
|
||||||
mapped_ctrl_c = FALSE; /* mappings are not used here */
|
mapped_ctrl_c = 0; // mappings are not used here
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
// flush output before waiting
|
// flush output before waiting
|
||||||
ui_flush();
|
ui_flush();
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/main.h"
|
#include "nvim/main.h"
|
||||||
#include "nvim/misc1.h"
|
#include "nvim/misc1.h"
|
||||||
|
#include "nvim/misc2.h"
|
||||||
|
|
||||||
#define READ_BUFFER_SIZE 0xfff
|
#define READ_BUFFER_SIZE 0xfff
|
||||||
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
|
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
|
||||||
@@ -357,7 +358,7 @@ static void read_cb(Stream *stream, RBuffer *buf, size_t c, void *data,
|
|||||||
|
|
||||||
static void process_interrupts(void)
|
static void process_interrupts(void)
|
||||||
{
|
{
|
||||||
if (mapped_ctrl_c) {
|
if ((mapped_ctrl_c | curbuf->b_mapped_ctrl_c) & get_real_state()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -77,9 +77,7 @@
|
|||||||
typedef struct terminal_state {
|
typedef struct terminal_state {
|
||||||
VimState state;
|
VimState state;
|
||||||
Terminal *term;
|
Terminal *term;
|
||||||
int save_state; // saved value of State
|
|
||||||
int save_rd; // saved value of RedrawingDisabled
|
int save_rd; // saved value of RedrawingDisabled
|
||||||
bool save_mapped_ctrl_c; // saved value of mapped_ctrl_c;
|
|
||||||
bool close;
|
bool close;
|
||||||
bool got_bs; // if the last input was <C-\>
|
bool got_bs; // if the last input was <C-\>
|
||||||
} TerminalState;
|
} TerminalState;
|
||||||
@@ -362,12 +360,11 @@ void terminal_enter(void)
|
|||||||
|
|
||||||
checkpcmark();
|
checkpcmark();
|
||||||
setpcmark();
|
setpcmark();
|
||||||
s->save_state = State;
|
int save_state = State;
|
||||||
s->save_rd = RedrawingDisabled;
|
s->save_rd = RedrawingDisabled;
|
||||||
State = TERM_FOCUS;
|
State = TERM_FOCUS;
|
||||||
|
mapped_ctrl_c |= TERM_FOCUS; // Always map CTRL-C to avoid interrupt.
|
||||||
RedrawingDisabled = false;
|
RedrawingDisabled = false;
|
||||||
s->save_mapped_ctrl_c = mapped_ctrl_c;
|
|
||||||
mapped_ctrl_c = true;
|
|
||||||
// go to the bottom when the terminal is focused
|
// go to the bottom when the terminal is focused
|
||||||
adjust_topline(s->term, buf, false);
|
adjust_topline(s->term, buf, false);
|
||||||
// erase the unfocused cursor
|
// erase the unfocused cursor
|
||||||
@@ -380,11 +377,10 @@ void terminal_enter(void)
|
|||||||
state_enter(&s->state);
|
state_enter(&s->state);
|
||||||
|
|
||||||
restart_edit = 0;
|
restart_edit = 0;
|
||||||
State = s->save_state;
|
State = save_state;
|
||||||
RedrawingDisabled = s->save_rd;
|
RedrawingDisabled = s->save_rd;
|
||||||
// draw the unfocused cursor
|
// draw the unfocused cursor
|
||||||
invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
|
invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
|
||||||
mapped_ctrl_c = s->save_mapped_ctrl_c;
|
|
||||||
unshowmode(true);
|
unshowmode(true);
|
||||||
redraw(curbuf->handle != s->term->buf_handle);
|
redraw(curbuf->handle != s->term->buf_handle);
|
||||||
ui_busy_stop();
|
ui_busy_stop();
|
||||||
|
@@ -551,11 +551,11 @@ static int included_patches[] = {
|
|||||||
576,
|
576,
|
||||||
575,
|
575,
|
||||||
574,
|
574,
|
||||||
// 573,
|
573,
|
||||||
572,
|
572,
|
||||||
// 571 NA
|
// 571 NA
|
||||||
// 570 NA
|
// 570 NA
|
||||||
// 569,
|
569,
|
||||||
568,
|
568,
|
||||||
567,
|
567,
|
||||||
566,
|
566,
|
||||||
|
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
local execute, expect, wait = helpers.execute, helpers.expect, helpers.wait
|
||||||
|
|
||||||
describe('mapping', function()
|
describe('mapping', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('is working', function()
|
it('abbreviations with р (0x80)', function()
|
||||||
insert([[
|
insert([[
|
||||||
test starts here:
|
test starts here:
|
||||||
]])
|
]])
|
||||||
@@ -16,6 +16,46 @@ describe('mapping', function()
|
|||||||
execute('inoreab чкпр vim')
|
execute('inoreab чкпр vim')
|
||||||
feed('GAчкпр <esc>')
|
feed('GAчкпр <esc>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
test starts here:
|
||||||
|
vim ]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('Ctrl-c works in Insert mode', function()
|
||||||
|
-- Mapping of ctrl-c in insert mode
|
||||||
|
execute('set cpo-=< cpo-=k')
|
||||||
|
execute('inoremap <c-c> <ctrl-c>')
|
||||||
|
execute('cnoremap <c-c> dummy')
|
||||||
|
execute('cunmap <c-c>')
|
||||||
|
feed('GA<cr>')
|
||||||
|
feed('TEST2: CTRL-C |')
|
||||||
|
wait()
|
||||||
|
feed('<c-c>A|<cr><esc>')
|
||||||
|
wait()
|
||||||
|
execute('unmap <c-c>')
|
||||||
|
execute('unmap! <c-c>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
TEST2: CTRL-C |<ctrl-c>A|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('Ctrl-c works in Visual mode', function()
|
||||||
|
execute([[vnoremap <c-c> :<C-u>$put ='vmap works'<cr>]])
|
||||||
|
feed('GV')
|
||||||
|
-- XXX: For some reason the mapping is only triggered
|
||||||
|
-- when <C-c> is in a separate feed command.
|
||||||
|
wait()
|
||||||
|
feed('<c-c>')
|
||||||
|
execute('vunmap <c-c>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
|
||||||
|
vmap works]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('langmap', function()
|
||||||
-- langmap should not get remapped in insert mode.
|
-- langmap should not get remapped in insert mode.
|
||||||
execute('inoremap { FAIL_ilangmap')
|
execute('inoremap { FAIL_ilangmap')
|
||||||
execute('set langmap=+{ langnoremap')
|
execute('set langmap=+{ langnoremap')
|
||||||
@@ -37,8 +77,7 @@ describe('mapping', function()
|
|||||||
|
|
||||||
-- Assert buffer contents.
|
-- Assert buffer contents.
|
||||||
expect([[
|
expect([[
|
||||||
test starts here:
|
|
||||||
vim
|
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
|
Reference in New Issue
Block a user