Skip to content

Commit bcc9532

Browse files
committed
Fixes microsoft#70490: resource is mandatory in ITextResourcePropertiesService
1 parent 6d4f831 commit bcc9532

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/vs/editor/common/services/modelServiceImpl.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,22 @@ export class ModelServiceImpl extends Disposable implements IModelService {
207207
};
208208
}
209209

210+
private _getEOL(resource: URI | undefined, language: string): string {
211+
if (resource) {
212+
return this._resourcePropertiesService.getEOL(resource, language);
213+
}
214+
const eol = this._configurationService.getValue<string>('files.eol', { overrideIdentifier: language });
215+
if (eol && eol !== 'auto') {
216+
return eol;
217+
}
218+
return platform.OS === platform.OperatingSystem.Linux || platform.OS === platform.OperatingSystem.Macintosh ? '\n' : '\r\n';
219+
}
220+
210221
public getCreationOptions(language: string, resource: URI | undefined, isForSimpleWidget: boolean): ITextModelCreationOptions {
211222
let creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];
212223
if (!creationOptions) {
213224
const editor = this._configurationService.getValue<IRawEditorConfig>('editor', { overrideIdentifier: language, resource });
214-
const eol = this._resourcePropertiesService.getEOL(resource, language);
225+
const eol = this._getEOL(resource, language);
215226
creationOptions = ModelServiceImpl._readModelOptions({ editor, eol }, isForSimpleWidget);
216227
this._modelCreationOptionsByLanguageAndResource[language + resource] = creationOptions;
217228
}

src/vs/editor/common/services/textResourceConfigurationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ export interface ITextResourcePropertiesService {
7575
/**
7676
* Returns the End of Line characters for the given resource
7777
*/
78-
getEOL(resource: URI | undefined, language?: string): string;
78+
getEOL(resource: URI, language?: string): string;
7979
}

0 commit comments

Comments
 (0)