Open jbyte opened 6 years ago
Sounds good to me, we can test the query generation better this way too.
Do we need to delete all lines in the buffer each time? We use enew!
inside the InsertResultsToNewBuffer
function anyway so the previous buffer would be removed (though still available in the jump list I guess).
Also it sounds like the pros outweight the cons so feel free to take a stab it, I would definitely like a cleaner codebase for this
I'll get started some time later today/tomorrow. The reason for deleting lines is mostly to use keepjumps
so the jump list doesn't get modified.
But I'll look into just modifying the buffer instead of delete and put. Maybe with the help of diff
?
As implied in this comment I think it would be a good idea to extract all SQL query generations (even if really simple) to their own functions which would enable a very easy and simple reload functionality for
SQHDatabase
,SQHTable
, andSQHResult
buffers when using key bindings that change their contents.Currently reloading is done like this:
open SQHDatabase
->dd to delete a database
->mysql#DropDatabase
(which creates the query, executes the query withmysql#GetResultsFromQuery
, deletes the buffer, and opens new buffer withmysql#ShowDatabases
)My idea is to make it work like this:
open SQHDatabase
->dd to delete a database
->mysql#DropDatabase
(which creates the query, executes the query, deletes all the lines in the current buffer, gets query for showing all the databases, and executes that query withmysql#GetResultsFromQuery
) Note: the empty buffer and fill with new contents would be a separate functionPros:
Cons: