Skip to content

Commit

Permalink
fix(test): fix list test fail
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Aug 17, 2019
1 parent ecb0b1f commit 4f85759
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions autoload/coc/api.vim
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ function! s:funcs.buf_set_lines(bufnr, start, end, strict, ...) abort
endif
if delCount
let start = startLnum + len(replacement)
let saved_reg = @"
silent execute start . ','.(start + delCount - 1).'d'
let @" = saved_reg
endif
endif
if changeBuffer
Expand Down
2 changes: 2 additions & 0 deletions autoload/coc/list.vim
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ function! coc#list#setlines(lines, append)
else
silent call append(0, a:lines)
let n = len(a:lines) + 1
let saved_reg = @"
silent execute n.',$d'
let @" = saved_reg
endif
endfunction

Expand Down
37 changes: 26 additions & 11 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54564,7 +54564,7 @@ class Plugin extends events_1.EventEmitter {
return false;
}
get version() {
return workspace_1.default.version + ( true ? '-' + "42c3ae12b1" : undefined);
return workspace_1.default.version + ( true ? '-' + "0baa83de90" : undefined);
}
async showInfo() {
if (!this.infoChannel) {
Expand Down Expand Up @@ -79738,12 +79738,9 @@ class ListManager {
this.ui.hide();
return;
}
let { isVim } = workspace_1.default;
let curr = await nvim.call('bufnr', '%');
if (curr == bufnr) {
this.prompt.start();
if (isVim)
nvim.command(`set t_ve=`, true);
}
else {
nvim.pauseNotification();
Expand Down Expand Up @@ -80132,7 +80129,7 @@ class ListManager {
// exclude control characer
if (code < 32 || code >= 127 && code <= 159)
return;
this.prompt.insertCharacter(s);
await this.prompt.acceptCharacter(s);
}
}
async onNormalInput(ch, _charmod) {
Expand Down Expand Up @@ -80775,6 +80772,9 @@ class Mappings {
this.add('insert', '<C-u>', () => {
prompt.removeAhead();
});
this.add('insert', '<C-r>', () => {
return prompt.insertRegister();
});
this.add('insert', '<C-d>', () => {
return manager.feedkeys('<C-d>');
});
Expand Down Expand Up @@ -81011,6 +81011,9 @@ class Mappings {
return prompt.removeTail();
case 'removeahead':
return prompt.removeAhead();
case 'insertregister':
await prompt.insertRegister();
return;
case 'paste':
await prompt.paste();
return;
Expand Down Expand Up @@ -81074,6 +81077,7 @@ class Prompt {
this._input = '';
this._mode = 'insert';
this.interactive = false;
this.requestInput = false;
this._onDidChangeInput = new vscode_languageserver_protocol_1.Emitter();
this.onDidChangeInput = this._onDidChangeInput.event;
}
Expand Down Expand Up @@ -81104,8 +81108,8 @@ class Prompt {
start(opts) {
if (opts) {
this.interactive = opts.interactive;
this._input = opts.input;
this.cusorIndex = opts.input.length;
this._input = opts.input;
this._mode = opts.mode;
this._matcher = opts.interactive ? '' : opts.matcher;
}
Expand Down Expand Up @@ -81231,8 +81235,21 @@ class Prompt {
this.drawPrompt();
this._onDidChangeInput.fire(this._input);
}
insertCharacter(ch) {
this.addText(ch);
async acceptCharacter(ch) {
if (this.requestInput) {
this.requestInput = false;
if (/^[0-9a-z"%#*+/:\-.]$/.test(ch)) {
let text = await this.nvim.call('getreg', ch);
text = text.replace(/\n/g, ' ');
this.addText(text);
}
}
else {
this.addText(ch);
}
}
async insertRegister() {
this.requestInput = true;
}
async paste() {
await this.eval('@*');
Expand Down Expand Up @@ -83302,9 +83319,7 @@ class ListUI {
this._onDidChange.fire();
if (workspace_1.default.isVim)
nvim.command('redraw', true);
nvim.resumeNotification(false, true).catch(_e => {
// noop
});
await nvim.resumeNotification();
}
restoreWindow() {
if (this.newTab)
Expand Down
2 changes: 2 additions & 0 deletions doc/coc.cnx
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ LIST MAPPINGS *coc-list-mappings*
<C-n> - 切换到下一个历史匹配输入。
<C-p> - 切换到上一个历史匹配输入。
<C-s> - 切换过滤匹配模式。
<C-r> - 从 vim 寄存器插入内容。
<Tab> - 选择操作项。

正常模式下默认快捷键:
Expand Down Expand Up @@ -1428,6 +1429,7 @@ s - 执行 'split' 操作.
'deletebackward' - 删除后一个字符
'removetail' - 删除后面全部字符
'removeahead' - 删除前面全部字符
'insertregister' - 从 vim 寄存器插入内容
'paste' - 插入系统粘贴板内容到当前位置
'eval' - 执行 viml 表达式并将结果插入到当前位置
'action' - 执行特定操作,使用 <tab> 查看当前列表支持操作
Expand Down
2 changes: 2 additions & 0 deletions doc/coc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,7 @@ Default mappings in insert mode:
<C-n> - navigate to next input in history.
<C-p> - navigate to previous input in history.
<C-s> - switch matcher for filter items.
<C-r> - insert content from vim register.
<Tab> - select action.

Default mappings in normal mode:
Expand Down Expand Up @@ -2115,6 +2116,7 @@ The mapping expression should be `command:arguments`, available commands:
'deletebackward' - remove next character.
'removetail' - remove characters afterwards.
'removeahead' - remove character ahead.
'insertregister' - insert content from vim register.
'paste' - append text from system clipboard to prompt.
'eval' - append text to prompt from result of viml expression.
'action' - execute action of list, use <tab> to find available actions.
Expand Down

0 comments on commit 4f85759

Please sign in to comment.