komsit37 / sublime-q

Sublime Text Plugin for q/kdb
MIT License
24 stars 9 forks source link

Namespace Code Completion Bug - Drops First Period #34

Closed swifty162 closed 1 year ago

swifty162 commented 2 years ago

When selecting a namespace from the predicted drop-down menu, the initial period is removed from the text. See examples below.

// a table called .my.table // typing below results in option for .my and also .my.table .m // select .my.table returns my.table // likewise typing .my.ta // choose .my.table from drop-down returns my.table

komsit37 commented 2 years ago

Yes, I have had this issue for a while too, but didn't get around to fix it.

I will document how completions is done here in case you or anyone wants to tackle it

Here is how it works:

  1. After every command is sent, the plugin executes additional q code to retrieve list of variables for completions https://github.com/komsit37/sublime-q/blob/496293b3be1b64659e7a120cd7bc46e2553a0fd7/q_event.py#L42

  2. reads the results, and set it to global settings so sublime text can read it later https://github.com/komsit37/sublime-q/blob/496293b3be1b64659e7a120cd7bc46e2553a0fd7/q_event.py#L71

  3. on_query_completions handles key type event, and return possible completions https://github.com/komsit37/sublime-q/blob/496293b3be1b64659e7a120cd7bc46e2553a0fd7/q_event.py#L17

Feel free to ask additional questions