From f004165e90940aedb360ec9d74d6348d4db0b19d Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Sat, 7 Jan 2017 20:17:50 +0100 Subject: [PATCH] GH-376 Fix paste --- SwiftNeoVim/NeoVimView.swift | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/SwiftNeoVim/NeoVimView.swift b/SwiftNeoVim/NeoVimView.swift index 0a7768f6..f891baa0 100644 --- a/SwiftNeoVim/NeoVimView.swift +++ b/SwiftNeoVim/NeoVimView.swift @@ -729,6 +729,11 @@ extension NeoVimView { return } + if self.mode == .Cmdline || self.mode == .Replace || self.mode == .Term { + self.agent.vimInput(self.vimPlainString(content)) + return + } + guard let curPasteMode = self.agent.boolOption("paste") else { self.ipcBecameInvalid("Reason: 'set paste' failed") return @@ -743,17 +748,15 @@ extension NeoVimView { pasteModeSet = false } + let resetPasteModeCmd = pasteModeSet ? ":set nopaste" : "" + switch self.mode { case .Insert: - self.agent.vimInput("\"+pa") - case .Cmdline, .Replace, .Term: - self.agent.vimInput(self.vimPlainString(content)) + self.agent.vimInput("\"+p\(resetPasteModeCmd)a") case .Normal, .Visual: - self.agent.vimInput("\"+p") - } - - if pasteModeSet { - self.agent.setBoolOption("paste", to: curPasteMode.boolValue) + self.agent.vimInput("\"+p\(resetPasteModeCmd)") + default: + return } }