Skip to content

Commit

Permalink
move token tree provider around, #63935
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 29, 2018
1 parent d3e7f79 commit 9c8a9df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 32 deletions.
29 changes: 0 additions & 29 deletions src/vs/editor/contrib/smartSelect/defaultProvider.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/vs/editor/contrib/smartSelect/smartSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { ITextModel } from 'vs/editor/common/model';
import * as modes from 'vs/editor/common/modes';
import { DefaultSelectionRangeProvider } from 'vs/editor/contrib/smartSelect/defaultProvider';
import * as nls from 'vs/nls';
import { MenuId } from 'vs/platform/actions/common/actions';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { TokenTreeSelectionRangeProvider } from 'vs/editor/contrib/smartSelect/tokenTree';

class SelectionRanges {

Expand Down Expand Up @@ -205,4 +205,4 @@ export function provideSelectionRanges(model: ITextModel, position: Position, to
return first(provider.map(pro => () => asThenable(() => pro.provideSelectionRanges(model, position, token))), arrays.isNonEmptyArray);
}

modes.SelectionRangeRegistry.register('*', new DefaultSelectionRangeProvider());
modes.SelectionRangeRegistry.register('*', new TokenTreeSelectionRangeProvider());
20 changes: 19 additions & 1 deletion src/vs/editor/contrib/smartSelect/tokenTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,25 @@ import { LineTokens } from 'vs/editor/common/core/lineTokens';
import { ignoreBracketsInToken } from 'vs/editor/common/modes/supports';
import { BracketsUtils, RichEditBrackets } from 'vs/editor/common/modes/supports/richEditBrackets';
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
import { LanguageId, StandardTokenType } from 'vs/editor/common/modes';
import { LanguageId, StandardTokenType, SelectionRangeProvider } from 'vs/editor/common/modes';

export class TokenTreeSelectionRangeProvider implements SelectionRangeProvider {

provideSelectionRanges(model: ITextModel, position: Position): Range[] {
let tree = build(model);
let node = find(tree, position);
let ranges: Range[] = [];
let lastRange: Range | undefined;
while (node) {
if (!lastRange || !Range.equalsRange(lastRange, node.range)) {
ranges.push(node.range);
}
lastRange = node.range;
node = node.parent;
}
return ranges;
}
}

export const enum TokenTreeBracket {
None = 0,
Expand Down

0 comments on commit 9c8a9df

Please sign in to comment.