File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,9 @@ const allCommands = [
130130 desc : "Go up the URL hierarchy" ,
131131 group : "navigation" ,
132132 advanced : true ,
133+ options : {
134+ popAnchor : "Remove the anchor/fragment/hash from the URL, if present." ,
135+ } ,
133136 } ,
134137
135138 {
Original file line number Diff line number Diff line change @@ -134,14 +134,22 @@ const NormalModeCommands = {
134134 } ,
135135
136136 // Url manipulation.
137- goUp ( count ) {
137+ goUp ( count , { registryEntry } ) {
138+ let c = count ;
138139 const url = new URL ( globalThis . location . href ) ;
139140
141+ // Pop anchor.
142+ if ( c > 0 && registryEntry . options . popAnchor && url . hash !== "" ) {
143+ url . hash = "" ;
144+ -- c ;
145+ }
146+
140147 // Pop path segments.
141- if ( url . pathname != "/" ) {
142- url . pathname = url . pathname . split ( "/" ) . slice ( 0 , - count ) . join ( "/" ) ;
148+ if ( c > 0 && url . pathname != "/" ) {
149+ url . pathname = url . pathname . split ( "/" ) . slice ( 0 , - c ) . join ( "/" ) ;
143150 url . search = "" ;
144151 url . hash = "" ;
152+ -- c ;
145153 }
146154
147155 if ( globalThis . location . href !== url . toString ( ) ) {
You can’t perform that action at this time.
0 commit comments