Skip to content
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

Handle inactive regions when determining folding ranges #6667

Merged
merged 3 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Extension/cpptools.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"recursiveIncludes": 100,
"gotoDefIntelliSense": 100,
"enhancedColorization": 100,
"minimumVSCodeVersion": "1.49.0"
"minimumVSCodeVersion": "1.52.0"
}
8 changes: 4 additions & 4 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"license": "SEE LICENSE IN LICENSE.txt",
"engines": {
"vscode": "^1.49.0"
"vscode": "^1.52.0"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-cpptools/issues",
Expand Down Expand Up @@ -2276,7 +2276,7 @@
"property.static": [
"variable.other.property.static"
],
"member.static": [
"method.static": [
"entity.name.function.member.static"
],
"macro": [
Expand Down Expand Up @@ -2352,7 +2352,7 @@
"@types/plist": "^3.0.2",
"@types/semver": "^7.1.0",
"@types/tmp": "^0.1.0",
"@types/vscode": "1.49.0",
"@types/vscode": "1.52.0",
"@types/webpack": "^4.39.0",
"@types/which": "^1.3.2",
"@types/yauzl": "^2.9.1",
Expand Down Expand Up @@ -2679,4 +2679,4 @@
"integrity": "CF1A01AA75275F76800F6BC1D289F2066DCEBCD983376D344ABF6B03FDB8FEA0"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import { DefaultClient, GetFoldingRangesParams, GetFoldingRangesRequest, Folding

export class FoldingRangeProvider implements vscode.FoldingRangeProvider {
private client: DefaultClient;
public onDidChangeFoldingRangesEvent = new vscode.EventEmitter<void>();
public onDidChangeFoldingRanges?: vscode.Event<void>;
constructor(client: DefaultClient) {
this.client = client;
this.onDidChangeFoldingRanges = this.onDidChangeFoldingRangesEvent.event;
}
provideFoldingRanges(document: vscode.TextDocument, context: vscode.FoldingContext,
token: vscode.CancellationToken): Promise<vscode.FoldingRange[]> {
Expand Down Expand Up @@ -52,4 +55,8 @@ export class FoldingRangeProvider implements vscode.FoldingRangeProvider {
});
});
}

public refresh(): void {
this.onDidChangeFoldingRangesEvent.fire();
}
}
15 changes: 11 additions & 4 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ enum SemanticTokenTypes {
referenceType = 5,
valueType = 6,
function = 7,
member = 8,
method = 8,
property = 9,
cliProperty = 10,
event = 11,
Expand Down Expand Up @@ -606,6 +606,7 @@ export class DefaultClient implements Client {
private documentFormattingProviderDisposable: vscode.Disposable | undefined;
private formattingRangeProviderDisposable: vscode.Disposable | undefined;
private onTypeFormattingProviderDisposable: vscode.Disposable | undefined;
private codeFoldingProvider: FoldingRangeProvider | undefined;
private codeFoldingProviderDisposable: vscode.Disposable | undefined;
private semanticTokensProvider: SemanticTokensProvider | undefined;
private semanticTokensProviderDisposable: vscode.Disposable | undefined;
Expand Down Expand Up @@ -838,7 +839,8 @@ export class DefaultClient implements Client {
this.onTypeFormattingProviderDisposable = vscode.languages.registerOnTypeFormattingEditProvider(this.documentSelector, new OnTypeFormattingEditProvider(this), ";", "}", "\n");
}
if (settings.codeFolding) {
this.codeFoldingProviderDisposable = vscode.languages.registerFoldingRangeProvider(this.documentSelector, new FoldingRangeProvider(this));
this.codeFoldingProvider = new FoldingRangeProvider(this);
this.codeFoldingProviderDisposable = vscode.languages.registerFoldingRangeProvider(this.documentSelector, this.codeFoldingProvider);
}
if (settings.enhancedColorization && this.semanticTokensLegend) {
this.semanticTokensProvider = new SemanticTokensProvider(this);
Expand Down Expand Up @@ -1347,16 +1349,18 @@ export class DefaultClient implements Client {
}
if (changedSettings["codeFolding"]) {
if (settings.codeFolding) {
this.codeFoldingProviderDisposable = vscode.languages.registerFoldingRangeProvider(this.documentSelector, new FoldingRangeProvider(this));
this.codeFoldingProvider = new FoldingRangeProvider(this);
this.codeFoldingProviderDisposable = vscode.languages.registerFoldingRangeProvider(this.documentSelector, this.codeFoldingProvider);
} else if (this.codeFoldingProviderDisposable) {
this.codeFoldingProviderDisposable.dispose();
this.codeFoldingProviderDisposable = undefined;
this.codeFoldingProvider = undefined;
}
}
if (changedSettings["enhancedColorization"]) {
if (settings.enhancedColorization && this.semanticTokensLegend) {
this.semanticTokensProvider = new SemanticTokensProvider(this);
this.semanticTokensProviderDisposable = vscode.languages.registerDocumentSemanticTokensProvider(this.documentSelector, new SemanticTokensProvider(this), this.semanticTokensLegend); ;
this.semanticTokensProviderDisposable = vscode.languages.registerDocumentSemanticTokensProvider(this.documentSelector, this.semanticTokensProvider, this.semanticTokensLegend); ;
} else if (this.semanticTokensProviderDisposable) {
this.semanticTokensProviderDisposable.dispose();
this.semanticTokensProviderDisposable = undefined;
Expand Down Expand Up @@ -2162,6 +2166,9 @@ export class DefaultClient implements Client {
}
}
}
if (this.codeFoldingProvider) {
this.codeFoldingProvider.refresh();
}
}

public logIntellisenseSetupTime(notification: IntelliSenseSetup): void {
Expand Down
8 changes: 4 additions & 4 deletions Extension/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@
dependencies:
source-map "^0.6.1"

"@types/vscode@1.49.0":
version "1.49.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.49.0.tgz#f3731d97d7e8b2697510eb26f6e6d04ee8c17352"
integrity sha512-wfNQmLmm1VdMBr6iuNdprWmC1YdrgZ9dQzadv+l2eSjJlElOdJw8OTm4RU4oGTBcfvG6RZI2jOcppkdSS18mZw==
"@types/vscode@1.52.0":
version "1.52.0"
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.52.0.tgz#61917968dd403932127fc4004a21fd8d69e4f61c"
integrity sha512-Kt3bvWzAvvF/WH9YEcrCICDp0Z7aHhJGhLJ1BxeyNP6yRjonWqWnAIh35/pXAjswAnWOABrYlF7SwXR9+1nnLA==

"@types/webpack-sources@*":
version "0.1.6"
Expand Down