Skip to content

Commit

Permalink
Copy OnEnter rules from html to php #39142
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Dec 4, 2017
1 parent 8a12b29 commit e13cc67
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion extensions/php/src/phpMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import PHPHoverProvider from './features/hoverProvider';
import PHPSignatureHelpProvider from './features/signatureHelpProvider';
import PHPValidationProvider from './features/validationProvider';

const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];

export function activate(context: vscode.ExtensionContext): any {

let validator = new PHPValidationProvider(context.workspaceState);
Expand All @@ -23,7 +25,6 @@ export function activate(context: vscode.ExtensionContext): any {
context.subscriptions.push(vscode.languages.registerHoverProvider('php', new PHPHoverProvider()));
context.subscriptions.push(vscode.languages.registerSignatureHelpProvider('php', new PHPSignatureHelpProvider(), '(', ','));


// need to set in the extension host as well as the completion provider uses it.
vscode.languages.setLanguageConfiguration('php', {
wordPattern: /(-?\d*\.\d\w*)|([^\-\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
Expand Down Expand Up @@ -53,6 +54,15 @@ export function activate(context: vscode.ExtensionContext): any {
// e.g. *-----*/|
beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,
action: { indentAction: vscode.IndentAction.None, removeText: 1 }
},
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>/i,
action: { indentAction: vscode.IndentAction.IndentOutdent }
},
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
action: { indentAction: vscode.IndentAction.Indent }
}
]
});
Expand Down

0 comments on commit e13cc67

Please sign in to comment.