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

RFC: strip trailing dots #651

Merged
merged 5 commits into from
Nov 8, 2019
Merged

RFC: strip trailing dots #651

merged 5 commits into from
Nov 8, 2019

Conversation

aviatesk
Copy link
Member

No description provided.

@aviatesk
Copy link
Member Author

aviatesk commented Nov 1, 2019

@pfitzseb can you make a quick review on this ?

This PR extends our getWord (and its internal -- getWordRangeAtBufferPosition) functions so that we can use different regexes for the beginning and the end of a word.

These lines were adapted from getBeginningOfCurrentWordBufferPosition and getEndOfCurrentWordBufferPosition respectively -- all the purpose is we can do the same things as those functions for a buffer point.

So the now the behavior of getWordAndRange (renamed from getWord) is like:

  • if both beginWordRegex and endWordRegex options are given, use them to detect each word boundary
  • if not, use wordRegex (default to our wordRegex): this is the previous behavior

As a result, we can extract head from head.field etc, which would help goto/datatip/docs, and also JunoLab/Atom.jl#203.

@pfitzseb
Copy link
Member

pfitzseb commented Nov 4, 2019

Sorry, I was kinda out of commission for the last couple of days.

Tbh, I don't like the

getWordAndRange (editor, options = {
  bufferPosition: undefined,
  wordRegex: wordRegex,
  beginWordRegex: undefined,
  endWordRegex: undefined
})

API. Do you anticipate any need for user defined regexps there?
Imho it would be cleaner to just split the current "word" on .s and indicate in which the cursor is. Or maybe return a

[
  {
    text: 'Foo',
    range: [0, 2]
  },
  {
    text: 'bar',
    range: '[4, 6]
  }
]

for Foo.bar.

@aviatesk
Copy link
Member Author

aviatesk commented Nov 4, 2019

Sorry, I was kinda out of commission for the last couple of days.

No worries :)

Tbh, I don't like the

getWordAndRange (editor, options = {
  bufferPosition: undefined,
  wordRegex: wordRegex,
  beginWordRegex: undefined,
  endWordRegex: undefined
})

API. Do you anticipate any need for user defined regexps there?

yeah, fair enough. I made such a complex API since I thought it would be more extensible, but I'm not coming up with the use cases of the user-defined regexes other than this case for now, to be honest.

Imho it would be cleaner to just split the current "word" on .s and indicate in which the cursor is. Or maybe return a

[
  {
    text: 'Foo',
    range: [0, 2]
  },
  {
    text: 'bar',
    range: '[4, 6]
  }
]

for Foo.bar.

And so this would be better solution -- stripping trailing dots would be fairly easy with this approach, too. I will try to change the function APIs then :)

@aviatesk aviatesk changed the title strip trailing dots RFC: strip trailing dots Nov 5, 2019
aviatesk added a commit that referenced this pull request Nov 5, 2019
@aviatesk
Copy link
Member Author

aviatesk commented Nov 5, 2019

okay, e9e9845 hopefully simplifies the logic.

aviatesk added a commit that referenced this pull request Nov 5, 2019
@pfitzseb pfitzseb merged commit 4197db5 into master Nov 8, 2019
@aviatesk aviatesk deleted the avi/partialdots branch November 8, 2019 10:08
aviatesk added a commit that referenced this pull request Nov 9, 2019
aviatesk added a commit that referenced this pull request Dec 12, 2019
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

Successfully merging this pull request may close these issues.

2 participants