nerdexam
Microsoft

GH-300 · Question #72

How can you use GitHub Copilot to get inline suggestions for refactoring your code? (Select two.)

The correct answer is A. By adding comments to your code and triggering a suggestion. E. By highlighting the code you want to fix, right-clicking, and selecting "Refactor using GitHub. GitHub Copilot supports inline refactoring in two primary ways covered by these answers. (A) Writing descriptive comments above or around your code signals Copilot's intent engine to generate a refactored version as an inline suggestion - this is a core workflow for guiding…

Use GitHub Copilot for code development

Question

How can you use GitHub Copilot to get inline suggestions for refactoring your code? (Select two.)

Options

  • ABy adding comments to your code and triggering a suggestion.
  • BBy highlighting the code you want to fix, right-clicking, and selecting "Fix using GitHub Copilot."
  • CBy running the gh copilot fix command.
  • DBy using the "/fix" command in GitHub Copilot in-line chat.
  • EBy highlighting the code you want to fix, right-clicking, and selecting "Refactor using GitHub

How the community answered

(18 responses)
  • A
    78% (14)
  • B
    11% (2)
  • C
    6% (1)
  • D
    6% (1)

Explanation

GitHub Copilot supports inline refactoring in two primary ways covered by these answers. (A) Writing descriptive comments above or around your code signals Copilot's intent engine to generate a refactored version as an inline suggestion - this is a core workflow for guiding Copilot. (E) Highlighting code, right-clicking, and selecting 'Refactor using GitHub Copilot' opens inline chat scoped to that selection and applies refactoring suggestions directly in the editor. Option B ('Fix using GitHub Copilot') targets bug fixes, not refactoring. Option C ('gh copilot fix') is a terminal CLI command, not an inline editor feature. Option D ('/fix') is also a fix command, not a refactor command - Copilot Chat uses '/fix' for errors and '/refactor' conceptually, but the right-click menu option in E is the correct inline refactor path.

Topics

#GitHub Copilot#Refactoring#Inline suggestions#Code Development

Community Discussion

No community discussion yet for this question.

Full GH-300 Practice