Skip to content

Update cursor after quick fix, using new data from dart-services #1210

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Aug 19, 2019

Conversation

RedBrogdon
Copy link
Contributor

No description provided.

@RedBrogdon
Copy link
Contributor Author

q.v. dart-archive/dart-services#442

@RedBrogdon
Copy link
Contributor Author

Fixes #1122, albeit in a fairly naive way. Once this is landed, I need to make a couple new issues for things like automatically adding an appropriate selection and simultaneous editing of linked edit groups.

/// provide an offset on the cursor's current line to represent the position
/// to which the cursor should move. This field allows for a character count
/// from the top of the file to be used instead.
final int absoluteCursorPosition;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would be a List<int> and _completionHelper be responsible for either using the first or all of the cursor positions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there are a few forms in which cursor info can be created by the analyzer:

  • Completions have a relative cursor offset, so that some have the cursor start immediately afterward, and method name completions have it start in between the parens. These could likely be converted to use the absolute one.
  • A single, absolute cursor position is used for a one-shot fix like "Move Widget Down."
  • A series of post-application "linked edit groups" require repeated multi-cursor, multi-selection editing by the user.

The first of those already worked when we showed up to the project. The second maps nicely to a single, absolute position, which is what I've done here. The third is much more complicated and is largely out of scope for this particular issue. As a stopgap, I'm translating the lined edit group info provided by the analyzer into a single absolute cursor position so we don't give the user something completely useless, but (as you point out), it's not ideal and will need to be revisited as our polishing efforts continue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third is much more complicated and is largely out of scope for this particular issue

I agree, I was just suggesting we make the type a List so that #3 goes more smoothly when we get to it.

Copy link
Member

@domesticmouse domesticmouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

@RedBrogdon
Copy link
Contributor Author

Decoupled analyzer from API, tested with both the old and new versions of dart-services without issue.

@johnpryan PTAL.

Copy link
Contributor

@johnpryan johnpryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RedBrogdon
Copy link
Contributor Author

LGTM - can we have an issue to track https://github.com/dart-lang/dart-pad/pull/1210/files#r314914346 ?

Done: #1213

@RedBrogdon RedBrogdon merged commit 0bc7393 into dart-lang:master Aug 19, 2019
@RedBrogdon RedBrogdon deleted the cursor branch August 19, 2019 18:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants