-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fixed multiline selection issue in edit mode #4514
base: main
Are you sure you want to change the base?
Fixed multiline selection issue in edit mode #4514
Conversation
✅ Deploy Preview for continuedev canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it will fix the problem I identified. I see a few style things that could be improved.
extensions/vscode/src/commands.ts
Outdated
selectionStart = editor.selection.end; | ||
selectionEnd = editor.selection.start; | ||
} else if (selectionStart.line === selectionEnd.line) { | ||
if (selectionStart.character > selectionEnd.character) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would read better if it was:
if (selectionStart.line > selectionEnd.line || (selectionStart.line == selectionEnd.line && ...)) {
selectionStart = editor.selection.end;
selectionEnd = editor.selection.start;
} else {
...
}
extensions/vscode/src/commands.ts
Outdated
const startFromCharZero = new vscode.Position(selectionStart.line, 0); | ||
const document = editor.document; | ||
let lastLine, lastChar; | ||
// Check if there is a trailing line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this comment should include is not what its doing but why, so more like:
// If the user selected onto a trailing line but didn't actually include any characters in it
// they don't want to include that line, so trim it off.
@@ -534,9 +534,38 @@ const getCommandsMap: ( | |||
return; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The should be some sort of comment here about what this is all about, would suggest:
// Edits are always of complete lines - we want to be consistent for that when we highlight,
// show the range in the sidebar, or send it to the model. To simplify, this, expand the range
// here to be complete lines.
43b168a
to
c38606b
Compare
The original behavior was only selecting the highlighted part and if there is nothing selected in the trailing line it still got seleced to the edit mode. This fix is to expand the selection start to the very beginning of first line and the selection end to the very end of the last line. In addtion, prevent the trailing line getting selecting if there is nothing in it. Granite-Code/granite-code#42
c38606b
to
742ca31
Compare
Description
The original behavior was only selecting the highlighted part and if there is nothing selected in the trailing line it still got seleced to the edit mode. This fix is to expand the selection start to the very beginning of first line and the selection end to the very end of the last line. In addtion, prevent the trailing line getting selecting if there is nothing in it.
Granite-Code/granite-code#42
Testing instructions