From 88c1c11d9371d0ded7f11a970e7b5f7a815a77c3 Mon Sep 17 00:00:00 2001 From: Ricardo Seriani Date: Thu, 26 Jan 2017 17:11:25 -0200 Subject: [PATCH] Added an option to disable rename sql result tab using @wbresult --- README.md | 2 ++ autoload/sw/sqlwindow.vim | 24 ++++++++++++++---------- doc/vim-sql-workbench.txt | 2 ++ plugin/sw.vim | 4 ++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5ca2f13..9cb4d5f 100644 --- a/README.md +++ b/README.md @@ -1122,6 +1122,8 @@ and * `g:sw_log_to_file`: If true, then the logging of the communication between `VIM` and `SQL Workbench/J` will be done in a file; otherwise, the logging is done in memory +* `g:sw_sql_name_result_tab`: If enable, rename the result tab using @wbresult; + default value: 1 ## Database explorer settings diff --git a/autoload/sw/sqlwindow.vim b/autoload/sw/sqlwindow.vim index 9ebba2d..614e79b 100644 --- a/autoload/sw/sqlwindow.vim +++ b/autoload/sw/sqlwindow.vim @@ -858,18 +858,22 @@ function! s:do_execute_sql(sql) endfunction function! sw#sqlwindow#execute_sql(sql) - let w:auto_added1 = "-- auto\n" - let w:auto_added2 = "-- end auto\n" - - if (!s:check_sql_buffer()) - return - endif let _sql = a:sql - let title = substitute(a:sql, '\v[\n\r]', ' ', 'g') - if strlen(title) > 255 - let title = title[:255] . '...' - endif + + if g:sw_sql_name_result_tab == 1 + + let w:auto_added1 = "-- auto\n" + let w:auto_added2 = "-- end auto\n" + + if (!s:check_sql_buffer()) + return + endif + let title = substitute(a:sql, '\v[\n\r]', ' ', 'g') + if strlen(title) > 255 + let title = title[:255] . '...' + endif let _sql = '-- @wbresult ' . title . "\n" . _sql + endif call s:do_execute_sql(_sql) endfunction diff --git a/doc/vim-sql-workbench.txt b/doc/vim-sql-workbench.txt index d7a1e87..9f2419f 100644 --- a/doc/vim-sql-workbench.txt +++ b/doc/vim-sql-workbench.txt @@ -1170,6 +1170,8 @@ SQL BUFFER SETTINGS: *vim-sql-workbench-sql_buffer_settings * `g:sw_log_to_file`: If true, then the logging of the communication between `VIM` and will be done in a file; otherwise, the logging is done in memory +* `g:sw_sql_name_result_tab`: If enable, rename the result tab using @wbresult; + default value: 1 -------------------------------------------------------------------------------- DATABASE EXPLORER SETTINGS *vim-sql-workbench-database_explorer_settings* diff --git a/plugin/sw.vim b/plugin/sw.vim index 6b73c17..6aa28b0 100644 --- a/plugin/sw.vim +++ b/plugin/sw.vim @@ -145,6 +145,10 @@ if !exists('g:sw_command_timer') let g:sw_command_timer = 1 endif +if !exists('g:sw_sql_name_result_tab') + let g:sw_sql_name_result_tab = 1 +endif + "if !exists('g:sw_overwrite_current_command') " let g:sw_overwrite_current_command = 0 "endif -- GitLab