diff --git a/autoload/coc/api.vim b/autoload/coc/api.vim index 81429dbb50e..e1e1630a233 100644 --- a/autoload/coc/api.vim +++ b/autoload/coc/api.vim @@ -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 diff --git a/autoload/coc/list.vim b/autoload/coc/list.vim index dad1f2a7e75..d82c02e7642 100644 --- a/autoload/coc/list.vim +++ b/autoload/coc/list.vim @@ -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 diff --git a/build/index.js b/build/index.js index a9539ff04f5..50b75f9934e 100644 --- a/build/index.js +++ b/build/index.js @@ -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) { @@ -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(); @@ -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) { @@ -80775,6 +80772,9 @@ class Mappings { this.add('insert', '', () => { prompt.removeAhead(); }); + this.add('insert', '', () => { + return prompt.insertRegister(); + }); this.add('insert', '', () => { return manager.feedkeys(''); }); @@ -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; @@ -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; } @@ -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; } @@ -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('@*'); @@ -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) diff --git a/doc/coc.cnx b/doc/coc.cnx index 1bcdd580d9a..1ca637e628f 100644 --- a/doc/coc.cnx +++ b/doc/coc.cnx @@ -1360,6 +1360,7 @@ LIST MAPPINGS *coc-list-mappings* - 切换到下一个历史匹配输入。 - 切换到上一个历史匹配输入。 - 切换过滤匹配模式。 + - 从 vim 寄存器插入内容。 - 选择操作项。 正常模式下默认快捷键: @@ -1428,6 +1429,7 @@ s - 执行 'split' 操作. 'deletebackward' - 删除后一个字符 'removetail' - 删除后面全部字符 'removeahead' - 删除前面全部字符 + 'insertregister' - 从 vim 寄存器插入内容 'paste' - 插入系统粘贴板内容到当前位置 'eval' - 执行 viml 表达式并将结果插入到当前位置 'action' - 执行特定操作,使用 查看当前列表支持操作 diff --git a/doc/coc.txt b/doc/coc.txt index 8de439cb70a..d12779235eb 100644 --- a/doc/coc.txt +++ b/doc/coc.txt @@ -2044,6 +2044,7 @@ Default mappings in insert mode: - navigate to next input in history. - navigate to previous input in history. - switch matcher for filter items. + - insert content from vim register. - select action. Default mappings in normal mode: @@ -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 to find available actions.