Change:
<!-- Use Help Report Issue to prefill these. --- VSCode Version: 1.27.2 (1.27.2) OS Version: MacOS 10.13.5 Also not working VsCode Version: Version 1.28.0-insider Steps to Reproduce: Highlight a function refactor move to new file <!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes/No Yes -- meaning it also fails to work with --disable-extensions I'm not sure why, the feature was working just fine before. I also tried setting Tried on multiple projects I see nothing in the Output pane. This feature was working prior to update. -- UPDATE: Also not working on the refactor menu: named export to default export function to module scope constant to enclosing scope
Update: can confirm the feature works on VS Code Version 1.25.1 (1.25.1), does not work on latest.
So even after setting , you don't see anything in the section of the output panel: <img width="870" alt="screen shot 2018-09-18 at 2 22 48 pm" src="https://user-"
Ah, yeah I see it now. I get this output just my highlighting text (not actually selecting "Move to new file"). I get no output when actually selecting Move To New File. Nothing happens. Works on VS Code 1.25 just fine (my current work around is to use this older build)
You can switch the typescript version independently of VS Code by following . In the latest VS Code insiders build, can you please try: Using . This was the version shipped with VS Code 1.25 Using . This has the latest fixes Do either of those fix the problem? Let me know if you have any questions about switching the typescript version in your workspace.
Also, does this happen for every refactoring you try to trigger? Does it happen in a new project if you just try to extract a simple expression like to a constant or function?
Hey, actually I'm using Typescript 3.0.3 on VS Code 1.25 by choosing the "Workspace" Typescript--and refactoring works as expected. refactor does not work in VSC 1.27, does work in VSC 1.25
To follow up, every option on the refactoring menu is not working in the latest VS Code, including the "Insiders" edition with no plugins or extensions running. All options work as expected on VS Code 1.25, I've not tried VS Code 1.26
Thanks. Unfortunately I'm unable to reproduce this on any machine so I need a bit more information from you: are the exact steps to take to show the code action menu and the select the desired refactoring? Are you using the mouse? The keyboard? Any specific keyboard configuration or international layout? a TypeScript file, if you write: Can you successfully trigger the quick fix that adds the missing super call in the constructor? collecting VS Code's internal logs for executing the quick fix: In VS Code, run the command Select . Restart VS Code and reproduce the problem Back in the output panel, share the output from the and sections
Hey, so I just noticed something. If I click on the lightbulb icon when I select code, it works! But it doesn't work if I select the code, right click on the selected code, choose "Refactor..." then choose "Move To New File" Log output Nothing else!
Oh here is potentially useful log, last one was from this one is from
Thanks I can repo now using the refactoring menu and I believe I have tracked this down to the refactor context menu seemingly not firing its actions when the user select an item. This may because the refactor context menu is triggered from within another context menu. I'll keep debugging tomorrow but let me know if you have any ideas on what may be going wrong here
does it reproduce with the custom menu but not the native menu?
This is on MacOS, so native context menus (Haven't been able to repo on windows at all yet)
that would be very weird. I am not even able to bring up anything when I click on "Refactoring...", is this broken? E.g. I selected some code and triggered it and was at least expecting something like "Extract method".
Ok I can reproduce, steps: click "Source actions..." click "Organize Imports" =nothing happens Works fine when invoked from the command palette. Reproduces in stable for me.
I verified that the "Organize Imports" action is triggered, so it does not seem to be an issue with the menu.
This is a bug with how we handle context menus. I these log points in <img width="728" alt="screen shot 2018-09-20 at 9 35 12 am" src="https://user-"which shows the following sequence of events. <img width="410" alt="screen shot 2018-09-20 at 9 30 30 am" src="https://user-"To summarize: the editor context menu the refactoring option opens another context menu this point we receive a generic event. event removes both the original editor context menu's click handler and the click handler for the refactor context menu we just created This explains why adding a slight delay when creating the refactor context menu fixes the problem
Where?
The editor and refactor menus both register a close event handler. When the editor context menu is closed, both of the menus receive the same close event so we end up removing the refactor menu’s click handler too even though is only just started showing

Discussion:
import { ipcRenderer, Event } from 'electron'; import { IContextMenuItem, ISerializableContextMenuItem, CONTEXT_MENU_CLOSE_CHANNEL, CONTEXT_MENU_CHANNEL, IPopupOptions, IContextMenuEvent } from 'vs/base/parts/contextmenu/common/contextmenu'; <del> let onClickChannelIds = 0; </del> <ins> let contextMenuIdPool = 0; </ins> export function popup(items: IContextMenuItem[], options?: IPopupOptions): void { const processedItems: IContextMenuItem[] = []; <del> const onClickChannel = `vscode:onContextMenu${onClickChannelIds++}`; const onClickChannelHandler = (event: Event, itemId: number, context: IContextMenuEvent) => processedItems[itemId].click(context); </del> <ins> const contextMenuId = contextMenuIdPool++; const onClickChannel = `vscode:onContextMenu${contextMenuId}`; const onClickChannelHandler = (_event: Event, itemId: number, context: IContextMenuEvent) => processedItems[itemId].click(context); </ins> ipcRenderer.once(onClickChannel, onClickChannelHandler); <del> ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, () => { </del> <ins> ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (_event: Event, closedContextMenuId: number) => { if (closedContextMenuId !== contextMenuId) { return; } </ins> ipcRenderer.removeListener(onClickChannel, onClickChannelHandler); if (options && options.onHide) {

} }); <del> ipcRenderer.send(CONTEXT_MENU_CHANNEL, items.map(item => createItem(item, processedItems)), onClickChannel, options); </del> <ins> ipcRenderer.send(CONTEXT_MENU_CHANNEL, contextMenuId, items.map(item => createItem(item, processedItems)), onClickChannel, options); </ins> } function createItem(item: IContextMenuItem, processedItems: IContextMenuItem[]): ISerializableContextMenuItem {

import { ISerializableContextMenuItem, CONTEXT_MENU_CLOSE_CHANNEL, CONTEXT_MENU_CHANNEL, IPopupOptions } from 'vs/base/parts/contextmenu/common/contextmenu'; export function registerContextMenuListener(): void { <del> ipcMain.on(CONTEXT_MENU_CHANNEL, (event: Event, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => { </del> <ins> ipcMain.on(CONTEXT_MENU_CHANNEL, (event: Event, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => { </ins> const menu = createMenu(event, onClickChannel, items); menu.popup({

y: options ? options.y : void 0, positioningItem: options ? options.positioningItem : void 0, callback: () => { <del> event.sender.send(CONTEXT_MENU_CLOSE_CHANNEL); </del> <ins> event.sender.send(CONTEXT_MENU_CLOSE_CHANNEL, contextMenuId); </ins> } }); });