Giter VIP home page Giter VIP logo

Comments (22)

jednano avatar jednano commented on August 20, 2024 4

There's nothing that can be done until Microsoft (or someone) fixes microsoft/vscode#824.

from editorconfig-vscode.

bizoo avatar bizoo commented on August 20, 2024 3

Still much needed for VSCode!
I don't think there's another way to correctly managed encoding without it.
So please look at it.

from editorconfig-vscode.

lygstate avatar lygstate commented on August 20, 2024 2

monitor this

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024 1

Nope.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024 1

@KUGA2 GitHub already shows it linked above. microsoft/vscode#824

from editorconfig-vscode.

snebjorn avatar snebjorn commented on August 20, 2024 1

Perhaps OP can be edited to encourage people (+friends & family) to go and upvote microsoft/vscode#824

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

I believe this is now possible with the files.encoding setting?

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

If I'm not mistaken, we can't override the workspace settings of the user so this should be implemented in the API.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

Ahh, you are correct.

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

Pinged them again to get the status on this API :)

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

@SamVerschueren can you reference (link to) the vscode issue here?

from editorconfig-vscode.

be5invis avatar be5invis commented on August 20, 2024

any progress?

from editorconfig-vscode.

brainz80 avatar brainz80 commented on August 20, 2024

Looking at vscodes source-code I found this (there's a feature to reopen a file with a different encoding):

vscode\src\vs\workbench\browser\parts\editor\editorStatus.ts:

return this.quickOpenService.pick(picks, {
	placeHolder: isReopenWithEncoding ? nls.localize('pickEncodingForReopen', "Select File Encoding to Reopen File") : nls.localize('pickEncodingForSave', "Select File Encoding to Save with"),
	autoFocus: { autoFocusIndex: typeof directMatchIndex === 'number' ? directMatchIndex : typeof aliasMatchIndex === 'number' ? aliasMatchIndex : void 0 }
}).then(encoding => {
	if (encoding) {
		activeEditor = this.editorService.getActiveEditor();
		encodingSupport = toEditorWithEncodingSupport(activeEditor.input);
		if (encodingSupport && encodingSupport.getEncoding() !== encoding.id) {
			encodingSupport.setEncoding(encoding.id, isReopenWithEncoding ? EncodingMode.Decode : EncodingMode.Encode); // Set new encoding
		}
	}
});

toEditorWithEncodingSupport looks like this:

function toEditorWithEncodingSupport(input: IEditorInput): IEncodingSupport {

	// Untitled Editor
	if (input instanceof UntitledEditorInput) {
		return input;
	}

	// Side by Side (diff) Editor
	if (input instanceof SideBySideEditorInput) {
		const masterEncodingSupport = toEditorWithEncodingSupport(input.master);
		const detailsEncodingSupport = toEditorWithEncodingSupport(input.details);

		if (masterEncodingSupport && detailsEncodingSupport) {
			return new SideBySideEditorEncodingSupport(masterEncodingSupport, detailsEncodingSupport);
		}

		return masterEncodingSupport;
	}

	// File or Resource Editor
	let encodingSupport = input as IFileEditorInput;
	if (types.areFunctions(encodingSupport.setEncoding, encodingSupport.getEncoding)) {
		return encodingSupport;
	}

	// Unsupported for any other editor
	return null;
}

Maybe this can be to some help. Could it be the necessary feature is there after all??

from editorconfig-vscode.

brainz80 avatar brainz80 commented on August 20, 2024

Throwing some more virtual balls:

Looking at vscode.d.ts I found this function:

/**
 * Get a workspace configuration object.
 *
 * When a section-identifier is provided only that part of the configuration
 * is returned. Dots in the section-identifier are interpreted as child-access,
 * like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
 *
 * When a resource is provided, configuration scoped to that resource is returned.
 *
 * @param section A dot-separated identifier.
 * @param resource A resource for which the configuration is asked for
 * @return The full configuration or a subset.
 */
export function getConfiguration(section?: string, resource?: Uri | null): WorkspaceConfiguration;

permalink to source

Example of usage:

const config = workspace.getConfiguration('launch', vscode.window.activeTextEditor.document.uri);

Could this be to any help?

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

@brainz80 your 2nd comment doesn't seem to have anything to do with encoding. The 1st one does, but those look like private methods, no?

from editorconfig-vscode.

brainz80 avatar brainz80 commented on August 20, 2024

@jedmao I guess your right. Looked a bit closer into the getConfiguration() -function and it seems the only data that can be queried though it has to do with launch and tasks settings:

Note: Workspace and Workspace Folder configurations contains launch and tasks settings. Their basename will be part of the section identifier. The following snippets shows how to retrieve all configurations from launch.json

https://code.visualstudio.com/docs/extensionAPI/vscode-api#WorkspaceConfiguration

As with the 1st comment they seem to be private methods; but maybe the logic in them could be to use?

I've tried to contact a couple of guys over at Microsoft with hopes of getting them to work on adding encoding support to the API. Unfortunately it seems they're more interested in working with their own bugs / feature-updates than taking on "user-reported" ones ... or so it seems at least.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

I'd rather wait until they have a supported API for this feature.

from editorconfig-vscode.

KUGA2 avatar KUGA2 commented on August 20, 2024

Any news on this?

from editorconfig-vscode.

brainz80 avatar brainz80 commented on August 20, 2024

from editorconfig-vscode.

KUGA2 avatar KUGA2 commented on August 20, 2024

Is there a issue or request on vscode we could vote on?

from editorconfig-vscode.

Masterxilo avatar Masterxilo commented on August 20, 2024

This is an absolute must. I am working with some legacy stuff here that has no idea about utf-8

from editorconfig-vscode.

lgaitan avatar lgaitan commented on August 20, 2024

Any update on this?
Maybe some help needed?

from editorconfig-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.