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

Inappropriate tab completions on 8-bit registers #3

Open
nitro2k01 opened this issue Nov 25, 2022 · 4 comments
Open

Inappropriate tab completions on 8-bit registers #3

nitro2k01 opened this issue Nov 25, 2022 · 4 comments

Comments

@nitro2k01
Copy link

I'm not sure if this is new, but I think this is the first time I've noticed it. I tab adjust comments, so it happens often that I press tab after an instruction. In the case of an 8 bit register (which of course just contains one character) Sublime greedily matches anything that happens to contain that character. So for example, if I press tab after a dec L it suggests that I may want to add an incLude statement there which is nonsense given the context. I can bypass this with shift-tab, but this is annoying. I can probably disable auto completions globally, but I actually use them so I'd rather not. Is this a fixable problem? I'm on 2.4.0, as auto updated by Sublime.

Screenshot_20221125_034924

@nitro2k01
Copy link
Author

The same also applies to other keywords, for example inc.

@ISSOtm
Copy link
Owner

ISSOtm commented Nov 26, 2022

I don't think this is a problem I can solve on my side, simply because of this:

Label:
    ld a, L|

If one were to press Tab here, are they looking to insert a tab after ld a, l, or are they looking to complete e.g. ld a, Label?

The solutions I see are:

  • Disable Tab triggering completion (this leaves e.g. Ctrl+Space); this may be doable in the language-specific settings.
  • Type a space, tab, then delete the space.
  • Avoid using tabs in this position.

As for reducing the amount of suggestions, it would be really difficult to even eliminate INCLUDE in this position due to RGBASM's very flexible syntax; at least, not without false positives that would certainly frustrate other users... 😕

@nitro2k01
Copy link
Author

nitro2k01 commented Nov 26, 2022

Apparently what I stumbled into are called snippets, rather than completions. You're right that that example is an ambiguous situation. What's not an ambiguous situation is inserting an include statement in the middle of an instruction. dec INCLUDE "file.asm" is not valid syntax. Doesn't Sublime allow a syntax package to decide where a certain snippet is allowed to be inserted based on context? All snippets seem to have <scope>source.rgbds</scope> which may be that functionality? (Currently set to match globally?)

I'm confused, though. I don't remember this ever being a problem until now, but the snippet files have been unchanged for 2-3 years since they were created. Could you have changed something somewhere else that made the string matching looser so it can now match on, say any character in the snippet trigger, as opposed only matching the beginning letters of the trigger?

Maybe it's not a change in the sublime-RGBDS package, but rather a change in Sublime itself?

@ISSOtm
Copy link
Owner

ISSOtm commented Nov 26, 2022

As I said, while that snippet is indeed not suitable after a dec, this would not solve the situation after a macro call, for example.

While snippets can indeed set to be triggered on specific contexts, I haven't been able to make that work satisfactorily, hence the current state. (I would have to spawn a context exactly where directives might be accepted, which is more difficult than at first sight.)

If you used not to get this, it might be a configuration change. I'd advise searching the Settings for anything related to completion (which snippets are just a source of, NB).

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