-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for charset
#35
Comments
I believe this is now possible with the |
If I'm not mistaken, we can't override the workspace settings of the user so this should be implemented in the API. |
Ahh, you are correct. |
Pinged them again to get the status on this API :) |
@SamVerschueren can you reference (link to) the vscode issue here? |
any progress? |
Nope. |
Still much needed for VSCode! |
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?? |
Throwing some more virtual balls: Looking at /**
* 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; Example of usage: const config = workspace.getConfiguration('launch', vscode.window.activeTextEditor.document.uri); Could this be to any help? |
@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? |
@jedmao I guess your right. Looked a bit closer into the
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. |
I'd rather wait until they have a supported API for this feature. |
Any news on this? |
@kuga unfortunately we'll have to wait until vscode devs add support for
charset to the API
ti 21. toukok. 2019 klo 16.23 KUGA2 <notifications@github.com> kirjoitti:
… Any news on this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#35?email_source=notifications&email_token=AAJTA52IETH5XRKF2VDYXOTPWPZVNA5CNFSM4B647T6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV34OXI#issuecomment-494389085>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJTA563BQZLWQ34EYYQZGTPWPZVNANCNFSM4B647T6A>
.
|
Is there a issue or request on vscode we could vote on? |
@KUGA2 GitHub already shows it linked above. microsoft/vscode#824 |
This is an absolute must. I am working with some legacy stuff here that has no idea about utf-8 |
Any update on this? |
There's nothing that can be done until Microsoft (or someone) fixes microsoft/vscode#824. |
Perhaps OP can be edited to encourage people (+friends & family) to go and upvote microsoft/vscode#824 |
monitor this |
Christ, I thought I was going nuts and couldn't write a working glob anymore until I got the desperate idea to check out the extension details. It's 2024 and vscode ironically does not let you safeguard the encoding of files that windows wants in not-utf8. You can't make this up. |
While it would be nice to have *.ps1 text working-tree-encoding=UTF-16 This will make sure that an error message will be displayed if a UTF-8 (no BOM) encoding is used for a newly created file: Footnotes |
They're working on it to bring that functionality via an API so we can use that. But it's not possible at the moment though.
The text was updated successfully, but these errors were encountered: