Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Break up tab boundary by space not by word #16

Merged
merged 4 commits into from
Mar 4, 2014

Conversation

JAStanton
Copy link
Contributor

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

@JAStanton JAStanton closed this Mar 2, 2014
@JAStanton JAStanton reopened this Mar 2, 2014
@JAStanton
Copy link
Contributor Author

@@ -1,6 +1,6 @@
{
"name": "snippets",
"version": "0.32.0",
"version": "0.32.1",
Copy link
Contributor

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/
Copy link
Contributor

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>

atom/language-coffee-script#7

Copy link
Contributor

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.

kevinsawicki added a commit that referenced this pull request Mar 4, 2014
Break up tab boundary by space not by word
@kevinsawicki kevinsawicki merged commit 6b3e9fb into atom:master Mar 4, 2014
@kevinsawicki
Copy link
Contributor

Thanks for adding this, much appreciated.

@@ -21,6 +24,21 @@ class SnippetExpansion
@editor.normalizeTabsInBufferRange(newRange)
@indentSubsequentLines(startPosition.row, snippet) if snippet.lineCount > 1

selectToBoundaryPosition: ->
Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants