Skip to content

Add separate function for VS Code arguments #4599

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

Merged
merged 2 commits into from
Dec 10, 2021

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Dec 10, 2021

The problem before was that the pop() caused the open in existing
instance functionality to break because the arguments no longer
contained the workspace or directory (files are left untouched).

We could simply remove the pop() but since workspace and folder are
not CLI arguments I think it makes sense to handle them in a separate
function which can be called at the point where they are needed. This
also lets us de-duplicate some logic since we create these arguments in
two spots and lets us skip this logic when we do not need it.

The pop() is still avoided because manipulating a passed-in object
in-place seems like a risky move. If we really need to do this we
should copy the positional argument array instead.

@code-asher code-asher requested a review from a team as a code owner December 10, 2021 00:01
The problem before was that the pop() caused the open in existing
instance functionality to break because the arguments no longer
contained the file.

We could simply remove the pop() but since `workspace` and `folder` are
not CLI arguments I think it makes sense to handle them in a separate
function which can be called at the point where they are needed.  This
also lets us de-duplicate some logic since we create these arguments in
two spots and lets us skip this logic when we do not need it.

The pop() is still avoided because manipulating a passed-in object
in-place seems like a risky move.  If we really need to do this we
should copy the positional argument array instead.
@codecov
Copy link

codecov bot commented Dec 10, 2021

Codecov Report

Merging #4599 (e844d1d) into main (3b91cff) will increase coverage by 0.52%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4599      +/-   ##
==========================================
+ Coverage   65.61%   66.14%   +0.52%     
==========================================
  Files          30       30              
  Lines        1652     1654       +2     
  Branches      330      331       +1     
==========================================
+ Hits         1084     1094      +10     
+ Misses        481      475       -6     
+ Partials       87       85       -2     
Impacted Files Coverage Δ
src/node/main.ts 50.53% <50.00%> (ø)
src/node/routes/vscode.ts 48.00% <50.00%> (+1.06%) ⬆️
src/node/cli.ts 83.78% <100.00%> (+3.16%) ⬆️

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 3b91cff...e844d1d. Read the comment docs.

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

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

refactoring, cleanup and tests - what a lovely friday gift! nice work 😎

@code-asher code-asher merged commit 9e583fa into coder:main Dec 10, 2021
@code-asher code-asher deleted the fix-open-folder branch December 10, 2021 18:01
@jsjoeio jsjoeio mentioned this pull request Dec 10, 2021
21 tasks
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.

2 participants