From ce0c28a6d0ff25a3fe86130ec20783cadda0c2a7 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 10 May 2017 13:53:21 -0700 Subject: [PATCH] Fix onEnter Rules Language Mode When There is a Selection (#26410) Fixes #26406 **Bug** If there is an active selection, the on Enter rules may use the wrong language mode which results in the incorrect `afterEnterText`. See #26406 for an example of this case **Fix** Use language mode from the selection and correctly compute offset when grabbing `afterEnterText` --- src/vs/editor/common/modes/languageConfigurationRegistry.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/common/modes/languageConfigurationRegistry.ts b/src/vs/editor/common/modes/languageConfigurationRegistry.ts index ae25a6533d4..1563ebc48de 100644 --- a/src/vs/editor/common/modes/languageConfigurationRegistry.ts +++ b/src/vs/editor/common/modes/languageConfigurationRegistry.ts @@ -288,8 +288,8 @@ export class LanguageConfigurationRegistryImpl { if (range.isEmpty()) { afterEnterText = scopedLineText.substr(range.startColumn - 1 - scopedLineTokens.firstCharOffset); } else { - let endScopedLineTokens = this.getScopedLineTokens(model, range.endLineNumber); - afterEnterText = endScopedLineTokens.getLineContent().substr(range.endColumn - 1); + const endScopedLineTokens = this.getScopedLineTokens(model, range.endLineNumber, range.endColumn); + afterEnterText = endScopedLineTokens.getLineContent().substr(range.endColumn - 1 - scopedLineTokens.firstCharOffset); } let lineNumber = range.startLineNumber; -- GitLab