You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to make an extension for vscode.
A function like this:
public insertNumbers() : void
{
let selections : vscode.Selection[] = this._textEditor.selections;
for (var i = 0; i < selections.length; i++)
{
let curSelection : vscode.Selection = selections[i];
this._textEditor.edit
(
function (builder)
{
builder.replace(curSelection, "test");
}
)
}
}
will only replace the text within the first selection:
Even if I convert the 'Selection' to 'Range':
let curRange = new vscode.Range(curSelection.start, curSelection.end);
then use
builder.replace(curRange, "test");
the same thing will happen.
TextEditorEdit.insert doesn't work as expected either.
It seems that the official sample: MDTools has the same problem: #4 with similar code
From the Extension API reference, it says that the primary selection is always at index 0. So the replace api will only work with the primary selection? Then how to make a selection a primary one?
Or this is a bug of vscode extension module?
The text was updated successfully, but these errors were encountered:
I'm not sure if this is the reason why it fails, but you should not call edit for every selection. I suggest to do the looping inside the edit callback.
@Inori - good catch - I fixed up the MDtools example sorry about that. @SamVerschueren - you were right on the money - embarrassing I remembered to do that in the general method but not in toUpper and toLower :)
I'm trying to make an extension for vscode.
A function like this:
will only replace the text within the first selection:
Even if I convert the 'Selection' to 'Range':
let curRange = new vscode.Range(curSelection.start, curSelection.end);
then use
builder.replace(curRange, "test");
the same thing will happen.
TextEditorEdit.insert
doesn't work as expected either.It seems that the official sample: MDTools has the same problem: #4 with similar code
From the Extension API reference, it says that the primary selection is always at index 0. So the replace api will only work with the primary selection? Then how to make a selection a primary one?
Or this is a bug of vscode extension module?
The text was updated successfully, but these errors were encountered: