-
Notifications
You must be signed in to change notification settings - Fork 102
Break up tab boundary by space not by word #16
Conversation
This fixes: |
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "snippets", | |||
"version": "0.32.0", | |||
"version": "0.32.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you back this out? The version gets bumped automatically when the package is published.
@@ -3,6 +3,7 @@ _ = require 'underscore-plus' | |||
|
|||
module.exports = | |||
class Snippet | |||
@prefixBoundary: /\s/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to add "
and '
to this regex for this CoffeeScript case that is currently broken:
"#<tab>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'll just do this in a separate PR, nevermind.
Break up tab boundary by space not by word
Thanks for adding this, much appreciated. |
@@ -21,6 +24,21 @@ class SnippetExpansion | |||
@editor.normalizeTabsInBufferRange(newRange) | |||
@indentSubsequentLines(startPosition.row, snippet) if snippet.lineCount > 1 | |||
|
|||
selectToBoundaryPosition: -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should really be inside of Cursor, something like
getPreviousBoundaryBuffer(boundary: Regex, breakOnStartOfLine: false)
Iterates characters previous to current cursor position until a boundary is been hit.
Because I need to use this again in another package, but I cannot make this happen. @kevinsawicki ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is getBeginningOfCurrentWordBufferPosition
which does take a wordRegex
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely looked into that already and it didn't work as expected for some reason, here is another use case:
\t....*..\t...|
vertical bar is cursor. periods is a simple space character. \t is tab. I want to look backward until I find my first non-whitespace character. Depending on if that's an asterix or not I do different things.
I will look into getBeginningOfCurrentWordBufferPosition
again because I definitely already did once before and I couldn't get it to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was able to use it in this PR: #18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I see how you're doing it. I must have done something wonky. the PR looks good to me btw +1
Current behavior: if you have this:
hello world[tab]
the tab will select
world
as the prefix to lookup tab triggers for because it's the current word.My modification does't look at the current word but instead looks backwards until it finds the first whitespace character, and uses that as the prefix e.g
hello @world[tab]
would use@world
as the prefix