Skip to content

Commit b85b55c

Browse files
committed
Merge branch 'master' into joh/registerTextDocumentProvider
2 parents f484123 + cc3ca46 commit b85b55c

16 files changed

Lines changed: 927 additions & 954 deletions

File tree

src/vs/base/browser/ui/countBadge/countBadge.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.monaco-count-badge {
77
padding: 0.2em 0.4em;
88
border-radius: 1em;
9-
font-size: 80%;
9+
font-size: 85%;
1010
font-weight: normal;
1111
text-align: center;
1212
background: #BEBEBE;

src/vs/base/browser/ui/findinput/findInput.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ export class FindInput {
4848
private caseSensitive:Checkbox.Checkbox;
4949
public domNode: HTMLElement;
5050
public validationNode: Builder.Builder;
51-
private inputNode:HTMLInputElement;
52-
private inputBox:InputBox.InputBox;
51+
public inputBox:InputBox.InputBox;
5352

5453
constructor(parent:HTMLElement, contextViewProvider: ContextView.IContextViewProvider, options?:IOptions) {
5554
this.contextViewProvider = contextViewProvider;
@@ -64,7 +63,6 @@ export class FindInput {
6463
this.wholeWords = null;
6564
this.caseSensitive = null;
6665
this.domNode = null;
67-
this.inputNode = null;
6866
this.inputBox = null;
6967
this.validationNode = null;
7068

src/vs/base/common/strings.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,34 @@ export function createRegExp(searchString: string, isRegex: boolean, matchCase:
202202
return new RegExp(searchString, modifiers);
203203
}
204204

205+
/**
206+
* Create a regular expression only if it is valid and it doesn't lead to endless loop.
207+
*/
208+
export function createSafeRegExp(searchString:string, isRegex:boolean, matchCase:boolean, wholeWord:boolean): RegExp {
209+
if (searchString === '') {
210+
return null;
211+
}
212+
213+
// Try to create a RegExp out of the params
214+
var regex:RegExp = null;
215+
try {
216+
regex = createRegExp(searchString, isRegex, matchCase, wholeWord);
217+
} catch (err) {
218+
return null;
219+
}
220+
221+
// Guard against endless loop RegExps & wrap around try-catch as very long regexes produce an exception when executed the first time
222+
try {
223+
if (regExpLeadsToEndlessLoop(regex)) {
224+
return null;
225+
}
226+
} catch (err) {
227+
return null;
228+
}
229+
230+
return regex;
231+
}
232+
205233
export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean {
206234
// Exit early if it's one of these special cases which are meant to match
207235
// against an empty string

src/vs/editor/browser/widget/media/tokens.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
.monaco-editor.vs .token.constant { color: #dd0000; }
1515
.monaco-editor.vs .token.string { color: #A31515; }
1616
.monaco-editor.vs .token.string.escape { color: #A31515; }
17-
.monaco-editor.vs .token.literal { color: #000000; }
1817
.monaco-editor.vs .token.literal.string { color: #A31515; }
1918
.monaco-editor.vs .token.literal.hex { color: #e07000; }
2019
.monaco-editor.vs .token.number { color: #09885A; }
@@ -106,7 +105,6 @@
106105
.monaco-editor.vs-dark .token.constant { color: #dd0000; }
107106
.monaco-editor.vs-dark .token.string { color: #CE9178; }
108107
.monaco-editor.vs-dark .token.string.escape { color: #CE9178; }
109-
.monaco-editor.vs-dark .token.literal { color: #e00000; }
110108
.monaco-editor.vs-dark .token.literal.hex { color: #e07000; }
111109
.monaco-editor.vs-dark .token.number { color: #B5CEA8; }
112110
.monaco-editor.vs-dark .token.number.hex { color: #5BB498; }
@@ -199,7 +197,6 @@
199197
.monaco-editor.hc-black .token.string { color: #CE9178; }
200198
.monaco-editor.hc-black .token.string.escape { color: #CE9178; }
201199

202-
.monaco-editor.hc-black .token.literal { color: #FFFFFF; }
203200
.monaco-editor.hc-black .token.literal.hex { color: #FFFFFF; }
204201
.monaco-editor.hc-black .token.number { color: #FFFFFF; }
205202
.monaco-editor.hc-black .token.number.hex { color: #FFFFFF; }
@@ -350,7 +347,6 @@
350347
.monaco-editor.vs .token.markup.raw
351348
.monaco-editor.vs .token.markup.other*/
352349

353-
.monaco-editor.vs .token.meta { color: #000000; }
354350
.monaco-editor.vs .token.meta.selector { color: #800000; }
355351
.monaco-editor.vs .token.meta.tag { color: #800000; }
356352
.monaco-editor.vs .token.meta.preprocessor { color: #0000FF; }
@@ -478,7 +474,6 @@
478474
.monaco-editor.vs-dark .token.markup.raw
479475
.monaco-editor.vs-dark .token.markup.other*/
480476

481-
.monaco-editor.vs-dark .token.meta { color: #D4D4D4; }
482477
.monaco-editor.vs-dark .token.meta.selector { color: #D7BA7D; }
483478
.monaco-editor.vs-dark .token.meta.tag { color: #808080; } /* gray for html/xml-tag brackets */
484479
.monaco-editor.vs-dark .token.meta.preprocessor { color: #569CD6; }
@@ -606,7 +601,6 @@
606601
.monaco-editor.hc-black .token.markup.raw
607602
.monaco-editor.hc-black .token.markup.other*/
608603

609-
.monaco-editor.hc-black .token.meta { color: #D4D4D4; }
610604
.monaco-editor.hc-black .token.meta.selector { color: #D7BA7D; }
611605
.monaco-editor.hc-black .token.meta.tag { color: #808080; } /* gray for html/xml-tag brackets */
612606
.monaco-editor.hc-black .token.meta.preprocessor { color: #569CD6; }

src/vs/editor/common/editorCommon.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,17 +1745,17 @@ export interface IModel extends IEditableTextModel, ITextModelWithMarkers, IToke
17451745
* @param matchCase Force the matching to match lower/upper case exactly.
17461746
* @param wholeWord Force the matching to match entire words only.
17471747
* @param limitResultCount Limit the number of results
1748-
* @return The ranges where the matches are. It is empty if not matches have been found.
1748+
* @return The ranges where the matches are. It is empty if no matches have been found.
17491749
*/
17501750
findMatches(searchString:string, searchScope:IRange, isRegex:boolean, matchCase:boolean, wholeWord:boolean, limitResultCount?:number): IEditorRange[];
17511751
/**
1752-
* Search the model.
1752+
* Search the model for the next match. Loops to the beginning of the model if needed.
17531753
* @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
17541754
* @param searchStart Start the searching at the specified position.
17551755
* @param isRegex Used to indicate that `searchString` is a regular expression.
17561756
* @param matchCase Force the matching to match lower/upper case exactly.
17571757
* @param wholeWord Force the matching to match entire words only.
1758-
* @return The ranges where the matches are. It is empty if not matches have been found.
1758+
* @return The range where the next match is. It is null if no next match has been found.
17591759
*/
17601760
findNextMatch(searchString:string, searchStart:IPosition, isRegex:boolean, matchCase:boolean, wholeWord:boolean): IEditorRange;
17611761

src/vs/editor/common/model/textModel.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -849,37 +849,12 @@ export class TextModel extends OrderGuaranteeEventEmitter implements EditorCommo
849849
throw new Error('Unknown EOL preference');
850850
}
851851

852-
private _toRegExp(searchString:string, isRegex:boolean, matchCase:boolean, wholeWord:boolean): RegExp {
853-
if (searchString === '') {
854-
return null;
855-
}
856-
857-
// Try to create a RegExp out of the params
858-
var regex:RegExp = null;
859-
try {
860-
regex = Strings.createRegExp(searchString, isRegex, matchCase, wholeWord);
861-
} catch (err) {
862-
return null;
863-
}
864-
865-
// Guard against endless loop RegExps & wrap around try-catch as very long regexes produce an exception when executed the first time
866-
try {
867-
if (Strings.regExpLeadsToEndlessLoop(regex)) {
868-
return null;
869-
}
870-
} catch (err) {
871-
return null;
872-
}
873-
874-
return regex;
875-
}
876-
877852
public findMatches(searchString:string, rawSearchScope:any, isRegex:boolean, matchCase:boolean, wholeWord:boolean, limitResultCount:number = LIMIT_FIND_COUNT): EditorCommon.IEditorRange[] {
878853
if (this._isDisposed) {
879854
throw new Error('Model.findMatches: Model is disposed');
880855
}
881856

882-
var regex = this._toRegExp(searchString, isRegex, matchCase, wholeWord);
857+
var regex = Strings.createSafeRegExp(searchString, isRegex, matchCase, wholeWord);
883858
if (!regex) {
884859
return [];
885860
}
@@ -899,7 +874,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements EditorCommo
899874
throw new Error('Model.findNextMatch: Model is disposed');
900875
}
901876

902-
var regex = this._toRegExp(searchString, isRegex, matchCase, wholeWord);
877+
var regex = Strings.createSafeRegExp(searchString, isRegex, matchCase, wholeWord);
903878
if (!regex) {
904879
return null;
905880
}

0 commit comments

Comments
 (0)