mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Fixes #144989
This commit is contained in:
parent
9fbc861fa4
commit
e80e4e6fd2
|
@ -26,7 +26,7 @@ import type { IGrammar, StackElement, IOnigLib, IRawTheme } from 'vscode-textmat
|
|||
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IValidGrammarDefinition, IValidEmbeddedLanguagesMap, IValidTokenTypeMap } from 'vs/workbench/services/textMate/common/TMScopeRegistry';
|
||||
import { TMGrammarFactory } from 'vs/workbench/services/textMate/common/TMGrammarFactory';
|
||||
import { missingTMGrammarErrorMessage, TMGrammarFactory } from 'vs/workbench/services/textMate/common/TMGrammarFactory';
|
||||
import { IExtensionResourceLoaderService } from 'vs/workbench/services/extensionResourceLoader/common/extensionResourceLoader';
|
||||
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { TMTokenization } from 'vs/workbench/services/textMate/common/TMTokenization';
|
||||
|
@ -266,6 +266,10 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
|
|||
});
|
||||
return new TMTokenizationSupportWithLineLimit(languageId, encodedLanguageId, tokenization, this._configurationService);
|
||||
} catch (err) {
|
||||
if (err.message && err.message === missingTMGrammarErrorMessage) {
|
||||
// Don't log this error message
|
||||
return null;
|
||||
}
|
||||
onUnexpectedError(err);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import type { IGrammar, Registry, StackElement, IRawTheme, IOnigLib } from 'vscode-textmate';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
@ -22,6 +21,8 @@ export interface ICreateGrammarResult {
|
|||
containsEmbeddedLanguages: boolean;
|
||||
}
|
||||
|
||||
export const missingTMGrammarErrorMessage = 'No TM Grammar registered for this language.';
|
||||
|
||||
export class TMGrammarFactory extends Disposable {
|
||||
|
||||
private readonly _host: ITMGrammarFactoryHost;
|
||||
|
@ -113,13 +114,13 @@ export class TMGrammarFactory extends Disposable {
|
|||
const scopeName = this._languageToScope.get(languageId);
|
||||
if (typeof scopeName !== 'string') {
|
||||
// No TM grammar defined
|
||||
return Promise.reject(new Error(nls.localize('no-tm-grammar', "No TM Grammar registered for this language.")));
|
||||
throw new Error(missingTMGrammarErrorMessage);
|
||||
}
|
||||
|
||||
const grammarDefinition = this._scopeRegistry.getGrammarDefinition(scopeName);
|
||||
if (!grammarDefinition) {
|
||||
// No TM grammar defined
|
||||
return Promise.reject(new Error(nls.localize('no-tm-grammar', "No TM Grammar registered for this language.")));
|
||||
throw new Error(missingTMGrammarErrorMessage);
|
||||
}
|
||||
|
||||
let embeddedLanguages = grammarDefinition.embeddedLanguages;
|
||||
|
@ -134,7 +135,17 @@ export class TMGrammarFactory extends Disposable {
|
|||
|
||||
const containsEmbeddedLanguages = (Object.keys(embeddedLanguages).length > 0);
|
||||
|
||||
const grammar = await this._grammarRegistry.loadGrammarWithConfiguration(scopeName, encodedLanguageId, { embeddedLanguages, tokenTypes: <any>grammarDefinition.tokenTypes });
|
||||
let grammar: IGrammar | null;
|
||||
|
||||
try {
|
||||
grammar = await this._grammarRegistry.loadGrammarWithConfiguration(scopeName, encodedLanguageId, { embeddedLanguages, tokenTypes: <any>grammarDefinition.tokenTypes });
|
||||
} catch (err) {
|
||||
if (err.message && err.message.startsWith('No grammar provided for')) {
|
||||
// No TM grammar defined
|
||||
throw new Error(missingTMGrammarErrorMessage);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
return {
|
||||
languageId: languageId,
|
||||
|
|
Loading…
Reference in a new issue