Skip to content

Commit a1494ab

Browse files
committed
inline values: use default word regex, do not massage values
1 parent 09ce0e4 commit a1494ab

1 file changed

Lines changed: 12 additions & 29 deletions

File tree

src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IAction, Action } from 'vs/base/common/actions';
1616
import { KeyCode } from 'vs/base/common/keyCodes';
1717
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
1818
import { StandardTokenType } from 'vs/editor/common/modes';
19+
import { DEFAULT_WORD_REGEXP } from 'vs/editor/common/model/wordHelper';
1920
import { ICodeEditor, IEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
2021
import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions';
2122
import { IDecorationOptions, IModelDecorationOptions, MouseTargetType, IModelDeltaDecoration, TrackedRangeStickiness, IPosition } from 'vs/editor/common/editorCommon';
@@ -36,16 +37,11 @@ import { FloatingClickWidget } from 'vs/workbench/parts/preferences/browser/pref
3637

3738
const HOVER_DELAY = 300;
3839
const LAUNCH_JSON_REGEX = /launch\.json$/;
39-
4040
const REMOVE_INLINE_VALUES_DELAY = 100;
4141
const INLINE_VALUE_DECORATION_KEY = 'inlinevaluedecoration';
42-
const MAX_INLINE_VALUE_LENGTH = 50; // Max string length of each inline 'x = y' string. If exceeded ... is added
43-
const MAX_INLINE_DECORATOR_LENGTH = 150; // Max string length of each inline decorator when debugging. If exceeded ... is added
4442
const MAX_NUM_INLINE_VALUES = 100; // JS Global scope can have 700+ entries. We want to limit ourselves for perf reasons
43+
const MAX_INLINE_DECORATOR_LENGTH = 150; // Max string length of each inline decorator when debugging. If exceeded ... is added
4544
const MAX_TOKENIZATION_LINE_LEN = 500; // If line is too long, then inline values for the line are skipped
46-
// LanguageConfigurationRegistry.getWordDefinition() return regexes that allow spaces and punctuation characters for languages like python
47-
// Using that approach is not viable so we are using a simple regex to look for word tokens.
48-
const WORD_REGEXP = /[\$\_A-Za-z][\$\_A-Za-z0-9]*/g;
4945

5046
@editorContribution
5147
export class DebugEditorContribution implements IDebugEditorContribution {
@@ -376,14 +372,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
376372
private createAllInlineValueDecorations(expressions: IExpression[]): IDecorationOptions[] {
377373
const nameValueMap = new Map<string, string>();
378374
for (let expr of expressions) {
379-
// Put ellipses in value if its too long. Preserve last char e.g "longstr…" or {a:true, b:true, …}
380-
let value = expr.value;
381-
if (value && value.length > MAX_INLINE_VALUE_LENGTH) {
382-
value = value.substr(0, MAX_INLINE_VALUE_LENGTH) + '…' + value[value.length - 1];
383-
}
384-
385-
nameValueMap.set(expr.name, value);
386-
375+
nameValueMap.set(expr.name, expr.value);
387376
// Limit the size of map. Too large can have a perf impact
388377
if (nameValueMap.size >= MAX_NUM_INLINE_VALUES) {
389378
break;
@@ -418,11 +407,6 @@ export class DebugEditorContribution implements IDebugEditorContribution {
418407
}
419408

420409
private createInlineValueDecoration(lineNumber: number, contentText: string): IDecorationOptions {
421-
const margin = '10px';
422-
const backgroundColor = 'rgba(255, 200, 0, 0.2)';
423-
const lightForegroundColor = 'rgba(0, 0, 0, 0.5)';
424-
const darkForegroundColor = 'rgba(255, 255, 255, 0.5)';
425-
426410
// If decoratorText is too long, trim and add ellipses. This could happen for minified files with everything on a single line
427411
if (contentText.length > MAX_INLINE_DECORATOR_LENGTH) {
428412
contentText = contentText.substr(0, MAX_INLINE_DECORATOR_LENGTH) + '...';
@@ -436,20 +420,19 @@ export class DebugEditorContribution implements IDebugEditorContribution {
436420
endColumn: Constants.MAX_SAFE_SMALL_INTEGER
437421
},
438422
renderOptions: {
423+
after: {
424+
contentText,
425+
backgroundColor: 'rgba(255, 200, 0, 0.2)',
426+
margin: '10px'
427+
},
439428
dark: {
440429
after: {
441-
contentText,
442-
backgroundColor,
443-
color: darkForegroundColor,
444-
margin
430+
color: 'rgba(255, 255, 255, 0.5)',
445431
}
446432
},
447433
light: {
448434
after: {
449-
contentText,
450-
backgroundColor,
451-
color: lightForegroundColor,
452-
margin
435+
color: 'rgba(0, 0, 0, 0.5)',
453436
}
454437
}
455438
}
@@ -476,8 +459,8 @@ export class DebugEditorContribution implements IDebugEditorContribution {
476459

477460
// Token is a word and not a comment
478461
if (token.tokenType === StandardTokenType.Other) {
479-
WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
480-
const wordMatch = WORD_REGEXP.exec(tokenStr);
462+
DEFAULT_WORD_REGEXP.lastIndex = 0; // We assume tokens will usually map 1:1 to words if they match
463+
const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
481464

482465
if (wordMatch) {
483466
const word = wordMatch[0];

0 commit comments

Comments
 (0)