diff --git a/src/providers/Formatting.ts b/src/providers/Formatting.ts
index 494308a..b0756b5 100644
--- a/src/providers/Formatting.ts
+++ b/src/providers/Formatting.ts
@@ -28,7 +28,7 @@ export class XmlFormattingEditProvider implements vsc.DocumentFormattingEditProv
         };
         
         let formatter = new XmlFormatter(formatterOptions);
-        let xml = formatter.format(document.getText());
+        let xml = formatter.format(document.getText(range));
         
         return [ vsc.TextEdit.replace(range, xml) ];
     }