Implemented fix for first parameter being a substring of the second p… (#106432)
* Implemented fix for first parameter being a substring of the second parameter * Addressed PR concern * Included edge cases * Changed to regex expression * Accounted for edge case * Added regex escaping
This commit is contained in:
parent
6781d16f05
commit
536ea46187
1 changed files with 5 additions and 3 deletions
|
@ -22,7 +22,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||||
import { editorHoverBackground, editorHoverBorder, textCodeBlockBackground, textLinkForeground, editorHoverForeground } from 'vs/platform/theme/common/colorRegistry';
|
import { editorHoverBackground, editorHoverBorder, textCodeBlockBackground, textLinkForeground, editorHoverForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||||
import { ParameterHintsModel, TriggerContext } from 'vs/editor/contrib/parameterHints/parameterHintsModel';
|
import { ParameterHintsModel, TriggerContext } from 'vs/editor/contrib/parameterHints/parameterHintsModel';
|
||||||
import { pad } from 'vs/base/common/strings';
|
import { pad, escapeRegExpCharacters } from 'vs/base/common/strings';
|
||||||
import { registerIcon, Codicon } from 'vs/base/common/codicons';
|
import { registerIcon, Codicon } from 'vs/base/common/codicons';
|
||||||
import { assertIsDefined } from 'vs/base/common/types';
|
import { assertIsDefined } from 'vs/base/common/types';
|
||||||
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
import { ColorScheme } from 'vs/platform/theme/common/theme';
|
||||||
|
@ -312,9 +312,11 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
|
||||||
} else if (Array.isArray(param.label)) {
|
} else if (Array.isArray(param.label)) {
|
||||||
return param.label;
|
return param.label;
|
||||||
} else {
|
} else {
|
||||||
const idx = signature.label.lastIndexOf(param.label);
|
const regex = new RegExp(`\\b${escapeRegExpCharacters(param.label)}\\b`, 'g');
|
||||||
|
regex.test(signature.label);
|
||||||
|
const idx = regex.lastIndex - param.label.length;
|
||||||
return idx >= 0
|
return idx >= 0
|
||||||
? [idx, idx + param.label.length]
|
? [idx, regex.lastIndex]
|
||||||
: [0, 0];
|
: [0, 0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue