Skip to content

Instantly share code, notes, and snippets.

@wolframkriesing
Created October 16, 2020 13:55
Show Gist options
  • Save wolframkriesing/2d8602b42ed5929b77b14ebf9c1dc322 to your computer and use it in GitHub Desktop.
Save wolframkriesing/2d8602b42ed5929b77b14ebf9c1dc322 to your computer and use it in GitHub Desktop.
// Variant 1
// Works as expected.
// I did:
// - select the first ocurence of `() => { console.log(); }` in line 8 AND
// - call WebStorm action "Introduce Variable"
// Webstorm offers me to replace all 3 places where the selected code is used (line 8, 10 and 13).
someFn({log: () => { console.log(); }});
const fn1 = () => {
someFn({log: () => { console.log(); }});
}
const fn2 = () => {
someFn({log: () => { console.log(); }});
}
// BUT
// Variant 2
// Does NOT work as expected.
// I did:
// - select the `() => { console.log(); }` in line 27 AND
// - call WebStorm action "Introduce Variable"
// Webstorm does NOT offer to replace all 2 occurences where the selected code is used, it only introduces a local variable above line 27
// I would expect it to look outside of it's accessible scope and find the occurence in line 30 too.
const fn1 = () => {
someFn({log: () => { console.log(); }});
}
const fn2 = () => {
someFn({log: () => { console.log(); }});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment