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

Don't apply edits on server #4133

Merged
merged 2 commits into from
Oct 22, 2020
Merged

Conversation

333fred
Copy link
Member

@333fred 333fred commented Oct 21, 2020

The code action provider and rename provider were expecting the server to apply the file changes, which then messes up incremental buffer changes. This sends for false for these parameters, and refactors the handling of code action responses to do the renames locally. As part of that, I also refactored the protocol to accurately reflect O#'s hierarchy, and share the edit building between the fixAllProvider and the runCodeAction provider. Fixes #4128.

The code action provider and rename provider were expecting the server to apply the file changes, which then messes up incremental buffer changes. This sends for false for these parameters, and refactors the handling of code action responses to do the renames locally. As part of that, I also refactored the protocol to accurately reflect O#'s hierarchy, and share the edit building between the fixAllProvider and the runCodeAction provider. Fixes dotnet#4128.
}
}

for (const change of changes) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual after change here.

let fileToOpen: Uri = null;
let renamedFiles: Uri[] = [];

for (let change of response.Changes) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The after change replaced this logic.

}

for (let change of response.Changes) {
if (change.ModificationType == FileModificationType.Opened)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if is unchanged.

if (change.ModificationType == FileModificationType.Modified)
{
let uri = vscode.Uri.file(change.FileName);
if (renamedFiles.some(r => r == uri))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is removed.

}

let edits: vscode.TextEdit[] = [];
for (let textChange of change.Changes) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is unchanged, other than using const where appropriate and correcting for the necessary cast on change to the correct type.

// If files were renamed that weren't the active editor, their tabs will
// be left open and marked as "deleted" by VS Code
let next = applyEditPromise;
if (renamedFiles.some(r => r.fsPath == vscode.window.activeTextEditor.document.uri.fsPath))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is removed and unneeded, as we now do the rename ourselves.

@codecov
Copy link

codecov bot commented Oct 21, 2020

Codecov Report

Merging #4133 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4133   +/-   ##
=======================================
  Coverage   85.99%   85.99%           
=======================================
  Files          60       60           
  Lines        1857     1857           
  Branches      215      215           
=======================================
  Hits         1597     1597           
  Misses        200      200           
  Partials       60       60           
Flag Coverage Δ
#integration 100.00% <ø> (ø)
#unit 85.99% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/omnisharp/protocol.ts 79.43% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f97ba36...1ca331b. Read the comment docs.

@JoeRobich JoeRobich merged commit dde0eaf into dotnet:master Oct 22, 2020
@333fred 333fred deleted the rename-not-apply branch October 22, 2020 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using "Rename symbol" corrupts semantic highlighting with 'random' color patterns
2 participants