Patchwork [2,of,2,contrib,v2] contrib: make editmergeps able to work with notepad++

login
register
mail settings
Submitter Kostia Balytskyi
Date May 20, 2017, 12:03 a.m.
Message ID <a13cabeef7fd58cde988.1495238581@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/20749/
State Accepted
Headers show

Comments

Kostia Balytskyi - May 20, 2017, 12:03 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1495238494 25200
#      Fri May 19 17:01:34 2017 -0700
# Node ID a13cabeef7fd58cde988b70b5911f78202c9eeb7
# Parent  a3098a10073eab5f0930e6bd6ddce6ba1de5349b
contrib: make editmergeps able to work with notepad++

Notepad++ has a different FIRSTLINE argument, so needs special handling.

Patch

diff --git a/contrib/editmergeps.ps1 b/contrib/editmergeps.ps1
--- a/contrib/editmergeps.ps1
+++ b/contrib/editmergeps.ps1
@@ -35,7 +35,8 @@  if ($ed -eq $nil)
   exit 1
 }
 
-if (($ed -eq "vim") -or ($ed -eq "emacs") -or ($ed -eq "nano"))
+if (($ed -eq "vim") -or ($ed -eq "emacs") -or `
+    ($ed -eq "nano") -or ($ed -eq "notepad++"))
 {
   $lines = Get-Lines
   $firstline = if ($lines.Length -gt 0) { $lines[0] } else { $nil }
@@ -46,6 +47,15 @@  if (($ed -eq "vim") -or ($ed -eq "emacs"
   # or the user stops editing the file
   while (($firstline -ne $nil) -and ($firstline -ne $previousline))
   {
+    if ($ed -eq "notepad++")
+    {
+        $linearg = "-n$firstline"
+    }
+    else
+    {
+        $linearg = "+$firstline"
+    }
+
     Start-Process -Wait $ed $linearg,$file
     $previousline = $firstline
     $lines = Get-Lines