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

Finalize smart select api #67872

Closed
jrieken opened this issue Feb 4, 2019 · 8 comments
Closed

Finalize smart select api #67872

jrieken opened this issue Feb 4, 2019 · 8 comments
Assignees
Labels
api-finalization feature-request Request for new features or functionality release-notes Release notes issues smart-select verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Feb 4, 2019

  • multiple vs single cursor
  • define kinds
@jrieken jrieken self-assigned this Feb 4, 2019
@jrieken jrieken added this to the February 2019 milestone Feb 4, 2019
@jrieken
Copy link
Member Author

jrieken commented Feb 11, 2019

@jrieken jrieken modified the milestones: February 2019, March 2019 Feb 25, 2019
@jrieken jrieken added the feature-request Request for new features or functionality label Feb 25, 2019
@jrieken
Copy link
Member Author

jrieken commented Mar 11, 2019

fyi @aeschli @octref - I have removed SelectionRangeKind as didn't yet know what to do with it. I have updated your extensions.

@jrieken
Copy link
Member Author

jrieken commented Mar 11, 2019

The lastest proposal is:

	export class SelectionRange {
		range: Range;
		constructor(range: Range);
	}

	export interface SelectionRangeProvider {
		/**
		 * Provide selection ranges for the given positions. Selection ranges should be computed individually and
		 * independend for each postion. The editor will merge and deduplicate ranges but providers must return sequences
		 * of ranges (per position) where a range must [contain](#Range.contains) and subsequent ranges.
		 *
		 * todo@joh
		 */
		provideSelectionRanges(document: TextDocument, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[][]>;
	}

	export namespace languages {
		export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable;
	}

@jrieken
Copy link
Member Author

jrieken commented Mar 11, 2019

An alternative, and something that would allow us to have sibling navigation, would be

export class SelectionRange {
  range: Range;
  parent?: SelectionRange;
  constructor(range: Range);
}

So, that the result is the selection range at the request position pointing upwards/outwards to its containing range. That would leave the door open to potentially add sibling pointers so that you can implements something like "go to next argument" or "go to previous field/method" (see
#69252). cc @mjbvz who brought up this idea before.

@octref
Copy link
Contributor

octref commented Mar 11, 2019

Re dropping Kind: Do we no longer consider #65308?

I do like with the alternative where we can support prev/next sibling.

@jrieken
Copy link
Member Author

jrieken commented Mar 11, 2019

Re dropping Kind: Do we no longer consider #65308?

We still do but we couldn't come with a reasonable list of kinds. Instead of holding back the API longer we should roll out things in stages.

@jrieken
Copy link
Member Author

jrieken commented Mar 12, 2019

fyi @aeschli @octref I have pushed a change that uses the parent pointer approach instead of the 2d array

@matklad
Copy link

matklad commented Mar 21, 2019

LGTM!

Though I'd expect that, rather than overloading extend selection for navigation by adding "next/prev" pointers, we should just add a dedicated API for that.

@jrieken jrieken added the verification-needed Verification of issue is requested label Mar 25, 2019
@octref octref added the verified Verification succeeded label Mar 26, 2019
@jrieken jrieken added the release-notes Release notes issues label Apr 1, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators May 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-finalization feature-request Request for new features or functionality release-notes Release notes issues smart-select verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants