src/vs/editor/common/languages/enterAction.ts

65 LOC · 13 covered · 52 uncovered · 1 ranges · 12 concepts · 1 introducers · 7 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/editor/common/commands/shiftCommand.ts · 278 LOCcommands/shiftCommand.tssrc/vs/editor/common/commands/trimTrailingWhitespaceCommand.ts · 126 LOCcommands/trimTrailingWhi…src/vs/editor/common/languages/supports/indentationLineProcessor.ts · 236 LOCsupports/indentationLine…src/vs/editor/contrib/indentation/common/indentation.ts · 115 LOCcommon/indentation.tssrc/vs/workbench/contrib/codeEditor/common/languageConfigurationExtensionPoint.ts · 888 LOCcommon/languageConfigura…JavaScript Issue #25437|occurrence=1, JavaScript Issue #141816|occurrence=1 · 0 introduced LOCJavaScript Issue #25437|…indentation.ts ×1 · 2 introduced LOCindentation.ts ×1textModelTokens.ts ×4 · 12 introduced LOCtextModelTokens.ts ×4JavaScript Enriching the hover|occurrence=1 · 0 introduced LOCJavaScript Enriching the…JavaScript Issue #86176|occurrence=1 · 0 introduced LOCJavaScript Issue #86176|…indentation.ts ×4 · 41 introduced LOCindentation.ts ×4indentation.ts ×1 · 2 introduced LOCindentation.ts ×1indentation.ts ×6 · 27 introduced LOCindentation.ts ×6languageConfigurationExtensionPoint.ts ×38 · 309 introduced LOClanguageConfigurationExt…languageConfigurationExtensionPoint.ts ×6 · 12 introduced LOClanguageConfigurationExt…shiftCommand.ts ×1 · 5 introduced LOCshiftCommand.ts ×1languageConfigurationExtensionPoint.ts ×19 · 775 introduced LOClanguageConfigurationExt…JavaScript Enriching the hover|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Auto-Reindentation - TypeScript/JavaScript Enriching the hover|occurrence=1JavaScript Enriching the…JavaScript Issue #141816|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Auto-Reindentation - TypeScript/JavaScript Issue #141816|occurrence=1JavaScript Issue #141816…JavaScript Issue #209859: do not do reindentation for tokens inside of a string|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Auto-Reindentation - TypeScript/JavaScript Issue #209859: do not do reindentation for tokens inside of a string|occurrence=1JavaScript Issue #209859…JavaScript Issue #25437|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Auto-Reindentation - TypeScript/JavaScript Issue #25437|occurrence=1JavaScript Issue #25437|…JavaScript Issue #29886|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Auto-Reindentation - TypeScript/JavaScript Issue #29886|occurrence=1JavaScript Issue #29886|…JavaScript Issue #86176|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Auto-Reindentation - TypeScript/JavaScript Issue #86176|occurrence=1JavaScript Issue #86176|…autoindent.test|title=Language Configuration Parsing Folding markers support object regex syntax with flags|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/codeEditor/test/node/autoindent.test|title=Language Configuration Parsing Folding markers support object regex syntax with flags|occurrence=1autoindent.test|title=La…Focused file · src/vs/editor/common/languages/enterAction.ts · 65 LOClanguages/enterAction.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- languageConfigurationExtensionPoint.ts ×19
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { Range } from '../core/range.js';
7 > import { ITextModel } from '../model.js';
8 > import { IndentAction, CompleteEnterAction } from './languageConfiguration.js';
9 > import { EditorAutoIndentStrategy } from '../config/editorOptions.js';
10 > import { getIndentationAtPosition, ILanguageConfigurationService } from './languageConfigurationRegistry.js';
11 > import { IndentationContextProcessor } from './supports/indentationLineProcessor.js';
12 >
13 > export function getEnterAction(
14 autoIndent: EditorAutoIndentStrategy,
15 model: ITextModel,
16 range: Range,
17 languageConfigurationService: ILanguageConfigurationService
18 ): CompleteEnterAction | null {
19 model.tokenization.forceTokenization(range.startLineNumber);
20 const languageId = model.getLanguageIdAtPosition(range.startLineNumber, range.startColumn);
21 const richEditSupport = languageConfigurationService.getLanguageConfiguration(languageId);
22 if (!richEditSupport) {
23 return null;
24 }
25 const indentationContextProcessor = new IndentationContextProcessor(model, languageConfigurationService);
26 const processedContextTokens = indentationContextProcessor.getProcessedTokenContextAroundRange(range);
27 const previousLineText = processedContextTokens.previousLineProcessedTokens.getLineContent();
28 const beforeEnterText = processedContextTokens.beforeRangeProcessedTokens.getLineContent();
29 const afterEnterText = processedContextTokens.afterRangeProcessedTokens.getLineContent();
30
31 const enterResult = richEditSupport.onEnter(autoIndent, previousLineText, beforeEnterText, afterEnterText);
32 if (!enterResult) {
33 return null;
34 }
35
36 const indentAction = enterResult.indentAction;
37 let appendText = enterResult.appendText;
38 const removeText = enterResult.removeText || 0;
39
40 // Here we add `\t` to appendText first because enterAction is leveraging appendText and removeText to change indentation.
41 if (!appendText) {
42 if (
43 (indentAction === IndentAction.Indent) ||
44 (indentAction === IndentAction.IndentOutdent)
45 ) {
46 appendText = '\t';
47 } else {
48 appendText = '';
49 }
50 } else if (indentAction === IndentAction.Indent) {
51 appendText = '\t' + appendText;
52 }
53
54 let indentation = getIndentationAtPosition(model, range.startLineNumber, range.startColumn);
55 if (removeText) {
56 indentation = indentation.substring(0, indentation.length - removeText);
57 }
58
59 return {
60 indentAction: indentAction,
61 appendText: appendText,
62 removeText: removeText,
63 indentation: indentation
64 };
65 }