Skip to content

Commit 35fa7f6

Browse files
authored
Plumbing for sending 'files.encoding' to native process (#6040)
1 parent 85936c3 commit 35fa7f6

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

Extension/ThirdPartyNotices.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,32 @@ The above copyright notice and this permission notice shall be included in all c
10271027

10281028
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10291029

1030+
1031+
-------------------------------------------------------------------
1032+
1033+
-------------------------------------------------------------------
1034+
1035+
libiconv - Pre-installed on target platforms: Mac, Linux
1036+
https://www.gnu.org/software/libiconv/
1037+
/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1038+
1039+
The GNU C Library is free software; you can redistribute it and/or
1040+
modify it under the terms of the GNU Lesser General Public
1041+
License as published by the Free Software Foundation; either
1042+
version 2.1 of the License, or (at your option) any later version.
1043+
1044+
The GNU C Library is distributed in the hope that it will be useful,
1045+
but WITHOUT ANY WARRANTY; without even the implied warranty of
1046+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1047+
Lesser General Public License for more details.
1048+
1049+
You should have received a copy of the GNU Lesser General Public
1050+
License along with the GNU C Library; if not, see
1051+
https://www.gnu.org/licenses/. */
1052+
1053+
http://www.gnu.org/licenses/lgpl.html
1054+
1055+
10301056
-------------------------------------------------------------------
10311057

10321058
-------------------------------------------------------------------

Extension/src/LanguageServer/client.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,7 @@ export class DefaultClient implements Client {
14201420
const settings_clangFormatStyle: (string | undefined)[] = [];
14211421
const settings_clangFormatFallbackStyle: (string | undefined)[] = [];
14221422
const settings_clangFormatSortIncludes: (string | undefined)[] = [];
1423+
const settings_filesEncoding: (string | undefined)[] = [];
14231424
const settings_filesExclude: (vscode.WorkspaceConfiguration | undefined)[] = [];
14241425
const settings_searchExclude: (vscode.WorkspaceConfiguration | undefined)[] = [];
14251426
const settings_intelliSenseEngine: (string | undefined)[] = [];
@@ -1589,6 +1590,7 @@ export class DefaultClient implements Client {
15891590
}
15901591

15911592
for (const otherSetting of otherSettings) {
1593+
settings_filesEncoding.push(otherSetting.filesEncoding);
15921594
settings_filesExclude.push(otherSetting.filesExclude);
15931595
settings_searchExclude.push(otherSetting.searchExclude);
15941596
}
@@ -1695,6 +1697,10 @@ export class DefaultClient implements Client {
16951697
clang_format_fallbackStyle: settings_clangFormatFallbackStyle,
16961698
clang_format_sortIncludes: settings_clangFormatSortIncludes,
16971699
extension_path: util.extensionPath,
1700+
files: {
1701+
encoding: settings_filesEncoding
1702+
},
1703+
workspace_fallback_encoding: workspaceOtherSettings.filesEncoding,
16981704
exclude_files: settings_filesExclude,
16991705
exclude_search: settings_searchExclude,
17001706
associations: workspaceOtherSettings.filesAssociations,
@@ -1772,6 +1778,9 @@ export class DefaultClient implements Client {
17721778
cppSettingsScoped["default"] = { systemIncludePath: cppSettingsResourceScoped.get("default.systemIncludePath") };
17731779
}
17741780

1781+
const otherSettingsFolder: OtherSettings = new OtherSettings(this.RootUri);
1782+
const otherSettingsWorkspace: OtherSettings = new OtherSettings();
1783+
17751784
// Unlike the LSP message, the event does not contain all settings as a payload, so we need to
17761785
// build a new JSON object with everything we need on the native side.
17771786
const settings: any = {
@@ -1791,9 +1800,11 @@ export class DefaultClient implements Client {
17911800
tabSize: vscode.workspace.getConfiguration("editor.tabSize", this.RootUri)
17921801
},
17931802
files: {
1803+
encoding: otherSettingsFolder.filesEncoding,
17941804
exclude: vscode.workspace.getConfiguration("files.exclude", this.RootUri),
17951805
associations: new OtherSettings().filesAssociations
17961806
},
1807+
workspace_fallback_encoding: otherSettingsWorkspace.filesEncoding,
17971808
search: {
17981809
exclude: vscode.workspace.getConfiguration("search.exclude", this.RootUri)
17991810
}

Extension/src/LanguageServer/settings.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Settings {
2424
* @param resource The path to a resource to which the settings should apply, or undefined if global settings are desired
2525
*/
2626
constructor(section: string, resource?: vscode.Uri) {
27-
this.settings = vscode.workspace.getConfiguration(section, resource ? resource : null);
27+
this.settings = vscode.workspace.getConfiguration(section, resource ? resource : undefined);
2828
}
2929

3030
protected get Section(): vscode.WorkspaceConfiguration { return this.settings; }
@@ -429,19 +429,20 @@ export interface TextMateRule {
429429
}
430430

431431
export class OtherSettings {
432-
private resource: vscode.Uri | null;
432+
private resource: vscode.Uri | undefined;
433433

434-
constructor(resource?: vscode.Uri | null) {
434+
constructor(resource?: vscode.Uri) {
435435
if (!resource) {
436-
resource = null;
436+
resource = undefined;
437437
}
438438
this.resource = resource;
439439
}
440440

441441
public get editorTabSize(): number | undefined { return vscode.workspace.getConfiguration("editor", this.resource).get<number>("tabSize"); }
442-
public get filesAssociations(): any { return vscode.workspace.getConfiguration("files", null).get("associations"); }
442+
public get filesEncoding(): string | undefined { return vscode.workspace.getConfiguration("files", { uri: this.resource, languageId: "cpp" }).get<string>("encoding"); }
443+
public get filesAssociations(): any { return vscode.workspace.getConfiguration("files").get("associations"); }
443444
public set filesAssociations(value: any) {
444-
vscode.workspace.getConfiguration("files", null).update("associations", value, vscode.ConfigurationTarget.Workspace);
445+
vscode.workspace.getConfiguration("files").update("associations", value, vscode.ConfigurationTarget.Workspace);
445446
}
446447
public get filesExclude(): vscode.WorkspaceConfiguration | undefined { return vscode.workspace.getConfiguration("files", this.resource).get("exclude"); }
447448
public get searchExclude(): vscode.WorkspaceConfiguration | undefined { return vscode.workspace.getConfiguration("search", this.resource).get("exclude"); }

0 commit comments

Comments
 (0)