Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrites existing values of t_SI, t_EI #46

Open
jfgoodall opened this issue Aug 6, 2021 · 1 comment
Open

Overwrites existing values of t_SI, t_EI #46

jfgoodall opened this issue Aug 6, 2021 · 1 comment

Comments

@jfgoodall
Copy link

vim-togglecursor overwites t_SI and t_EI preventing other settings from being applied (i.e. as shown in https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode).

Patch to allow additional, external settings to be supplied as option variables:

From 41e441f9d9305448b5cf48421f6b5b723b287a26 Mon Sep 17 00:00:00 2001
From: James Goodall
Date: Fri, 6 Aug 2021 13:58:47 -0700
Subject: [PATCH] Allow existing values of t_SI, t_EI to be preserved

---
 plugin/togglecursor.vim | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/plugin/togglecursor.vim b/plugin/togglecursor.vim
index 07cbdfb..8824642 100644
--- a/plugin/togglecursor.vim
+++ b/plugin/togglecursor.vim
@@ -136,6 +136,14 @@ if !exists("g:togglecursor_disable_tmux")
     let g:togglecursor_disable_tmux = 0
 endif
 
+if !exists("g:togglecursor_t_SI_external")
+    let g:togglecursor_t_SI_external = ''
+endif
+
+if !exists("g:togglecursor_t_EI_external")
+    let g:togglecursor_t_SI_external = ''
+endif
+
 " -------------------------------------------------------------
 " Functions
 " -------------------------------------------------------------
@@ -173,8 +181,8 @@ function! s:ToggleCursorInit()
         return
     endif
 
-    let &t_EI = s:GetEscapeCode(g:togglecursor_default)
-    let &t_SI = s:GetEscapeCode(g:togglecursor_insert)
+    let &t_EI = s:GetEscapeCode(g:togglecursor_default) . g:togglecursor_t_EI_external
+    let &t_SI = g:togglecursor_t_SI_external . s:GetEscapeCode(g:togglecursor_insert)
     if s:sr_supported
         let &t_SR = s:GetEscapeCode(g:togglecursor_replace)
     endif
@@ -189,10 +197,10 @@ endfunction
 
 function! s:ToggleCursorByMode()
     if v:insertmode == 'r' || v:insertmode == 'v'
-        let &t_SI = s:GetEscapeCode(g:togglecursor_replace)
+        let &t_SI = g:togglecursor_t_SI_external . s:GetEscapeCode(g:togglecursor_insert)
     else
         " Default to the insert mode cursor.
-        let &t_SI = s:GetEscapeCode(g:togglecursor_insert)
+        let &t_SI = g:togglecursor_t_SI_external . s:GetEscapeCode(g:togglecursor_insert)
     endif
 endfunction
 
-- 
1.8.3.1
@jszakmeister
Copy link
Owner

Thank you for filing an issue. I'll have to think on this a bit more... all the terminal handling stuff can be rather tricky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants