Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

gushuro
Copy link
Contributor

@gushuro gushuro commented Mar 16, 2018

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

Don't preview incomplete abbreviations
@gushuro
Copy link
Contributor Author

gushuro commented Mar 16, 2018

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).

@ledniy
Copy link

ledniy commented Aug 24, 2018

Really missing this after switching from Atom, any plans to release it?

@ramya-rao-a ramya-rao-a removed their assignment Nov 19, 2018
@aeschli aeschli added the emmet Emmet related issues label Aug 26, 2020
@joaomoreno joaomoreno changed the base branch from master to main February 15, 2021 08:51
@rzhao271 rzhao271 added the feature-request Request for new features or functionality label Feb 17, 2021
@rzhao271 rzhao271 added this to the February 2021 milestone Feb 17, 2021
@@ -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, '')) {
Copy link
Contributor

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

@rzhao271
Copy link
Contributor

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?

Copy link
Contributor

@rzhao271 rzhao271 left a 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) {
Copy link
Contributor

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;
Copy link
Contributor

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 = '';
Copy link
Contributor

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.

@rzhao271 rzhao271 requested review from rzhao271 and removed request for ramya-rao-a February 17, 2021 17:05
@rzhao271 rzhao271 modified the milestones: February 2021, March 2021 Feb 17, 2021
Copy link
Contributor

@rzhao271 rzhao271 left a 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

@rzhao271 rzhao271 modified the milestones: March 2021, April 2021 Mar 22, 2021
@rzhao271
Copy link
Contributor

Closing for now.

@rzhao271 rzhao271 closed this Apr 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
emmet Emmet related issues feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants