<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import nls = require('vs/nls');

import * as Paths from 'vs/base/common/paths';
import {fileExists} from 'vs/base/node/pfs';
import {createPath} from 'vs/workbench/parts/emmet/node/fileAccessor';
import {EmmetEditorAction} from 'vs/workbench/parts/emmet/node/emmetActions';
import {Action} from 'vs/base/common/actions';

import {CommonEditorRegistry, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {IEditorActionDescriptorData, ICommonCodeEditor} from 'vs/editor/common/editorCommon';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IQuickOpenService, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IMessageService, Severity} from 'vs/platform/message/common/message';

class EncodeDecodeDataUrlAction extends EmmetEditorAction {

	static ID = 'editor.emmet.action.encodeDecodeDataUrl';
	private imageFilePath: string = null;

	constructor(descriptor: IEditorActionDescriptorData, editor: ICommonCodeEditor,
		@IConfigurationService configurationService: IConfigurationService,
		@IQuickOpenService private quickOpenService: IQuickOpenService,
		@IMessageService private messageService: IMessageService) {
		super(descriptor, editor, configurationService);
	}

	public runEmmetAction(_emmet) {
		const currentLine = this.editorAccessor.getCurrentLine();
		if (!this.isDataURI(currentLine)) {
			this.encodeDecode(_emmet);
			return;
		}
<commit_msg>Fix #8316 (error decoding DataURI without workspace) (#8352)<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import nls = require('vs/nls');

import * as Paths from 'vs/base/common/paths';
import {fileExists} from 'vs/base/node/pfs';
import {createPath} from 'vs/workbench/parts/emmet/node/fileAccessor';
import {EmmetEditorAction} from 'vs/workbench/parts/emmet/node/emmetActions';
import {Action} from 'vs/base/common/actions';

import {CommonEditorRegistry, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {IEditorActionDescriptorData, ICommonCodeEditor} from 'vs/editor/common/editorCommon';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {IQuickOpenService, IInputOptions} from 'vs/workbench/services/quickopen/common/quickOpenService';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';

class EncodeDecodeDataUrlAction extends EmmetEditorAction {

	static ID = 'editor.emmet.action.encodeDecodeDataUrl';
	private imageFilePath: string = null;

	constructor(descriptor: IEditorActionDescriptorData, editor: ICommonCodeEditor,
		@IConfigurationService configurationService: IConfigurationService,
		@IWorkspaceContextService private workspaceContext: IWorkspaceContextService,
		@IQuickOpenService private quickOpenService: IQuickOpenService,
		@IMessageService private messageService: IMessageService) {
		super(descriptor, editor, configurationService);
	}

	public runEmmetAction(_emmet) {
		const currentLine = this.editorAccessor.getCurrentLine();
		if (!this.isDataURI(currentLine)) {
			this.encodeDecode(_emmet);
			return;
		}

		if (!this.workspaceContext.getWorkspace()) {
			const message = nls.localize('noWorkspace', "Decoding **data:url** image are only available on a workspace folder.");
			this.messageService.show(Severity.Warning, message);
			return;
		}

{'fraction_non_alphanumeric': 0.18391356542617046, 'fraction_numerical': 0.0019207683073229293, 'mean_word_length': 3.816184971098266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5758706', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1067, 'n_words': 253}