-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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
Remember last abbreviations used in wrap with abbreviation. #46006
Conversation
Don't preview incomplete abbreviations
On second thoughts, we might want to have the whole previous abbreviation selected when invoking the command again, so it's easier to write a whole new one (and users can still press right arrow to un-select it). |
Really missing this after switching from Atom, any plans to release it? |
@@ -161,13 +164,26 @@ function doWrapping(individualLines: boolean, args: any) { | |||
let extractedResults = helper.extractAbbreviationFromText(inputAbbreviation); | |||
if (!extractedResults) { | |||
return Promise.resolve(inPreview); | |||
} else if (extractedResults.abbreviation !== inputAbbreviation) { | |||
// Not clear what should we do in this case. Warn the user? How? | |||
} else if (extractedResults.abbreviation !== inputAbbreviation.replace(/\|[a-zA-Z]+/g, '')) { |
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.
Sanity check: is the regex taking out filters? Might be worth adding a comment about it
I know it's been almost three years, but this actually looks like a nice workaround in the meantime considering how:
@gushuro wondering if you can update the PR? |
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.
Since this also changes the UX, I'm wondering whether it can be put behind an extension settings flag, in case a user is already used to directly typing an expansion into the inputbox.
} | ||
|
||
let { abbreviation, filter } = extractedResults; | ||
if (definitive) { | ||
const revertPromise = inPreview ? revertPreview() : Promise.resolve(); | ||
if (individualLines) { |
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.
You can just assume individualLines = true
now, so there's no need for this check
@@ -201,7 +217,8 @@ function doWrapping(individualLines: boolean, args: any) { | |||
} | |||
return ''; | |||
} | |||
const abbreviationPromise = (args && args['abbreviation']) ? Promise.resolve(args['abbreviation']) : vscode.window.showInputBox({ prompt: 'Enter Abbreviation', validateInput: inputChanged }); | |||
let value = individualLines ? previousAbbreviationIndividualLines : previousAbbreviation; |
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.
You can just assume individualLines = true
now, so there's no need for this check
@@ -16,6 +16,9 @@ const inlineElements = ['a', 'abbr', 'acronym', 'applet', 'b', 'basefont', 'bdo' | |||
's', 'samp', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'sup', | |||
'textarea', 'tt', 'u', 'var']; | |||
|
|||
let previousAbbreviation = ''; | |||
let previousAbbreviationIndividualLines = ''; |
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.
You can just assume individualLines = true
now, so I think just having previousAbbreviation
is ok.
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.
Slight GitHub glitch, marking as Request changes again
Closing for now. |
When executing the Wrap with Abbreviation (resp. Individual Lines one) command, now the inputBox comes prefilled with the previous value entered, and cursor at the end.
Also, made a change so that we don't modify preview in wrap with abbreviation when the abbreviation typed is incomplete.
See #23169 and #40096