When prefix starts with a whitespace, the suggestion will disappear after typing first two letters
Closed this issue · 3 comments
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
If the first letter of a snippet's prefix is whitespace, the suggestion will disappear after user typing the first two letters of prefix. If taking whitespace character as a part of snippets prefix is not recommended, it should report an error when user save the snippets file, otherwise the suggestions should show when the prefix matches one of the snippets.
Steps to Reproduce
- Add a snippet, be sure the first letter of the prefix is a whitespace, like this:
'propertyFunction':
prefix: ' pf'
body: '''
($1) {
$2
},
'''
- Open an empty js file in text editor, type a letter
a
and a whitespace. - Look at the suggestions.
- Follow the whitespace, type the letter
p
. - Look at the suggestions.
Expected behavior:
After typing letter p
, the suggestion item propertyFunction
still shows in the suggestion list.
Actual behavior: The suggestion item propertyFunction
disappeared.
Reproduces how often: 100%
Versions
Atom : 1.22.0-beta0
Electron: 1.6.9
Chrome : 56.0.2924.87
Node : 7.4.0
apm 1.18.4
npm 3.10.10
node 6.9.5 x64
python 3.6.1
git 2.13.5
OS: MacOS Sierra 10.12.6
Additional Information
After typing a whitespace:
After typing a whitespace and a letter p
:
Pretty sure it's because the prefix now becomes pf
instead of <space>pf
.
I imagine this is (sort of) intentional behaviour. Otherwise, it may as well consider the entire line to be part of the prefix (seeing as word breaks would be ignored), a change in behaviour of which could be annoying to those other packages that rely on the prefix provided by the autocomplete-plus
package. Although the snippets
package does allow arbitrary prefixes, I believe allowing this in autocomplete-snippets
could lead to unexpected or desirable results.
The way the snippets
package seems to handle it is to look at all snippets and make the prefix regex require one or more of any observed characters to be present (so if spaces are present in a snippet definition, they will be allowed). This could probably be adpated here too, but good luck finding someone who will put in the time to do this. It seems like a lot of work to put in, especially when considering how annoying it would be to have whitespace in snippets anyway. As it is, autocomplete-snippets
currently relies on the prefix provided by autocomplete-plus
, as seen here.
Conclusion: People should avoid using whitespace as a part of snippet.