@jsjoeio/code-server
Version:
Run VS Code on a remote server.
2 lines • 26.7 kB
JavaScript
!function(e,t){for(var n in t)e[n]=t[n]}(exports,function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t){e.exports=require("vscode")},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o,i,s,a,c=n(1),l=n(11),u=Object.prototype.toString;function d(e){return void 0!==e}function g(e){return"[object Number]"===u.call(e)}function h(e){return"[object String]"===u.call(e)}function f(e){return JSON.parse(l.readFileSync(e,"utf8"))}function m(e,t){return a&&(e="["+e.replace(/[aouei]/g,"$&$&")+"]"),0===t.length?e:e.replace(/\{(\d+)\}/g,(function(e,n){var r=n[0],o=t[r],i=e;return"string"==typeof o?i=o:"number"!=typeof o&&"boolean"!=typeof o&&null!=o||(i=String(o)),i}))}function p(e){return function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];return g(t)?t>=e.length?void console.error("Broken localize call found. Index out of bounds. Stacktrace is\n: "+new Error("").stack):m(e[t],r):h(n)?(console.warn("Message "+n+" didn't get externalized correctly."),m(n,r)):void console.error("Broken localize call found. Stacktrace is\n: "+new Error("").stack)}}function w(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return m(t,n)}function v(e,t){return i[e]=t,t}function C(e,t){var n,r,o,i=c.join(s.cacheRoot,e.id+"-"+e.hash+".json"),a=!1,u=!1;try{return n=JSON.parse(l.readFileSync(i,{encoding:"utf8",flag:"r"})),r=i,o=new Date,l.utimes(r,o,o,(function(){})),n}catch(e){if("ENOENT"===e.code)u=!0;else{if(!(e instanceof SyntaxError))throw e;console.log("Syntax error parsing message bundle: "+e.message+"."),l.unlink(i,(function(e){e&&console.error("Deleting corrupted bundle "+i+" failed.")})),a=!0}}if(!(n=function(e,t){var n=s.translationsConfig[e.id];if(n){var r=f(n).contents,o=f(c.join(t,"nls.metadata.json")),i=Object.create(null);for(var a in o){var l=o[a],u=r[e.outDir+"/"+a];if(u){for(var d=[],g=0;g<l.keys.length;g++){var m=l.keys[g],p=u[h(m)?m:m.key];void 0===p&&(p=l.messages[g]),d.push(p)}i[a]=d}else i[a]=l.messages}return i}}(e,t))||a)return n;if(u)try{l.writeFileSync(i,JSON.stringify(n),{encoding:"utf8",flag:"wx"})}catch(e){if("EEXIST"===e.code)return n;throw e}return n}function y(e){try{return function(e){var t=f(c.join(e,"nls.metadata.json")),n=Object.create(null);for(var r in t){var o=t[r];n[r]=o.messages}return n}(e)}catch(e){return void console.log("Generating default bundle from meta data failed.",e)}}function b(e,t){var n;if(!0===s.languagePackSupport&&void 0!==s.cacheRoot&&void 0!==s.languagePackId&&void 0!==s.translationsConfigFile&&void 0!==s.translationsConfig)try{n=C(e,t)}catch(e){console.log("Load or create bundle failed ",e)}if(!n){if(s.languagePackSupport)return y(t);var r=function(e){for(var t=s.locale;t;){var n=c.join(e,"nls.bundle."+t+".json");if(l.existsSync(n))return n;var r=t.lastIndexOf("-");t=r>0?t.substring(0,r):void 0}if(void 0===t){n=c.join(e,"nls.bundle.json");if(l.existsSync(n))return n}}(t);if(r)try{return f(r)}catch(e){console.log("Loading in the box message bundle failed.",e)}n=y(t)}return n}function k(e){if(!e)return w;var t=c.extname(e);if(t&&(e=e.substr(0,e.length-t.length)),s.messageFormat===r.both||s.messageFormat===r.bundle){var n=function(e){for(var t,n=c.dirname(e);t=c.join(n,"nls.metadata.header.json"),!l.existsSync(t);){var r=c.dirname(n);if(r===n){t=void 0;break}n=r}return t}(e);if(n){var o=c.dirname(n),u=i[o];if(void 0===u)try{var g=JSON.parse(l.readFileSync(n,"utf8"));try{var h=b(g,o);u=v(o,h?{header:g,nlsBundle:h}:null)}catch(e){console.error("Failed to load nls bundle",e),u=v(o,null)}}catch(e){console.error("Failed to read header file",e),u=v(o,null)}if(u){var m=e.substr(o.length+1).replace(/\\/g,"/"),C=u.nlsBundle[m];return void 0===C?(console.error("Messages for file "+e+" not found. See console for details."),function(){return"Messages not found."}):p(C)}}}if(s.messageFormat===r.both||s.messageFormat===r.file)try{var y=f(function(e){var t;if(s.cacheLanguageResolution&&t)t=t;else{if(a||!s.locale)t=".nls.json";else for(var n=s.locale;n;){var r=".nls."+n+".json";if(l.existsSync(e+r)){t=r;break}var o=n.lastIndexOf("-");o>0?n=n.substring(0,o):(t=".nls.json",n=null)}s.cacheLanguageResolution&&(t=t)}return e+t}(e));return Array.isArray(y)?p(y):d(y.messages)&&d(y.keys)?p(y.messages):(console.error("String bundle '"+e+"' uses an unsupported format."),function(){return"File bundle has unsupported format. See console for details"})}catch(e){"ENOENT"!==e.code&&console.error("Failed to load single file bundle",e)}return console.error("Failed to load message bundle for file "+e),function(){return"Failed to load message bundle. See console for details."}}!function(e){e.file="file",e.bundle="bundle",e.both="both"}(r=t.MessageFormat||(t.MessageFormat={})),function(e){e.is=function(e){var t=e;return t&&d(t.key)&&d(t.comment)}}(o||(o={})),function(){if(s={locale:void 0,languagePackSupport:!1,cacheLanguageResolution:!0,messageFormat:r.bundle},h(process.env.VSCODE_NLS_CONFIG))try{var e=JSON.parse(process.env.VSCODE_NLS_CONFIG);if(h(e.locale)&&(s.locale=e.locale.toLowerCase()),(!0===(t=e._languagePackSupport)||!1===t)&&(s.languagePackSupport=e._languagePackSupport),h(e._cacheRoot)&&(s.cacheRoot=e._cacheRoot),h(e._languagePackId)&&(s.languagePackId=e._languagePackId),h(e._translationsConfigFile)){s.translationsConfigFile=e._translationsConfigFile;try{s.translationsConfig=f(s.translationsConfigFile)}catch(t){e._corruptedFile&&l.writeFile(e._corruptedFile,"corrupted","utf8",(function(e){console.error(e)}))}}}catch(e){}var t;a="pseudo"===s.locale,void 0,i=Object.create(null)}(),t.loadMessageBundle=k,t.config=function(e){return e&&(h(e.locale)&&(s.locale=e.locale.toLowerCase(),void 0,i=Object.create(null)),void 0!==e.messageFormat&&(s.messageFormat=e.messageFormat)),a="pseudo"===s.locale,k}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0);class o{constructor(e){this.context=e}begin(){this.context.subscriptions.push(r.workspace.registerTextDocumentContentProvider(o.scheme,this))}dispose(){}async provideTextDocumentContent(e){try{const{scheme:t,ranges:n}=JSON.parse(e.query),o=await r.workspace.openTextDocument(e.with({scheme:t,query:""}));let i="",s=new r.Position(0,0);n.forEach(e=>{let[t,n]=e;const[a,c]=t,[l,u]=n;i+=o.getText(new r.Range(s.line,s.character,l.line,l.character)),i+=o.getText(new r.Range(a.line,a.character,c.line,c.character)),s=new r.Position(u.line,u.character)});let a=o.lineAt(o.lineCount-1).range.end;return i+=o.getText(new r.Range(s.line,s.character,a.line,a.character)),i}catch(e){return await r.window.showErrorMessage("Unable to show comparison"),null}}}t.default=o,o.scheme="merge-conflict.conflict-diff"},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deactivate=t.activate=void 0;const r=n(5);t.activate=function(e){const t=new r.default(e);t.begin(),e.subscriptions.push(t)},t.deactivate=function(){}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0),o=n(6),i=n(10),s=n(12),a=n(3),c=n(13);t.default=class{constructor(e){this.context=e,this.services=[]}begin(){let e=this.createExtensionConfiguration();const t=new o.default;this.services.push(t,new s.default(t),new i.default(t),new a.default(this.context),new c.default(this.context,t)),this.services.forEach(t=>{t.begin&&t.begin instanceof Function&&t.begin(e)}),r.workspace.onDidChangeConfiguration(()=>{this.services.forEach(e=>{e.configurationUpdated&&e.configurationUpdated instanceof Function&&e.configurationUpdated(this.createExtensionConfiguration())})})}createExtensionConfiguration(){const e=r.workspace.getConfiguration("merge-conflict"),t=e.get("codeLens.enabled",!0),n=e.get("decorators.enabled",!0);return{enableCodeLens:t,enableDecorations:n,enableEditorOverview:n}}dispose(){this.services.forEach(e=>e.dispose()),this.services=[]}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(7),o=n(9);class i{constructor(e,t){this.origins=new Set,this.origins.add(t),this.delayTask=new o.Delayer(e)}addOrigin(e){return this.origins.has(e),!1}hasOrigin(e){return this.origins.has(e)}}class s{constructor(e,t){this.parent=e,this.origin=t}getConflicts(e){return this.parent.getConflicts(e,this.origin)}isPending(e){return this.parent.isPending(e,this.origin)}forget(e){this.parent.forget(e)}}t.default=class{constructor(){this.cache=new Map,this.delayExpireTime=0}getConflicts(e,t){let n=this.getCacheKey(e);if(!n)return Promise.resolve(this.getConflictsOrEmpty(e,[t]));let r=this.cache.get(n);return r?r.addOrigin(t):(r=new i(this.delayExpireTime,t),this.cache.set(n,r)),r.delayTask.trigger(()=>{let t=this.getConflictsOrEmpty(e,Array.from(r.origins));return this.cache&&this.cache.delete(n),t})}isPending(e,t){if(!e)return!1;let n=this.getCacheKey(e);if(!n)return!1;const r=this.cache.get(n);return!!r&&r.hasOrigin(t)}createTracker(e){return new s(this,e)}forget(e){let t=this.getCacheKey(e);t&&this.cache.delete(t)}dispose(){this.cache.clear()}getConflictsOrEmpty(e,t){if(!r.MergeConflictParser.containsConflict(e))return[];return r.MergeConflictParser.scanDocument(e)}getCacheKey(e){return e.uri?e.uri.toString():null}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergeConflictParser=void 0;const r=n(0),o=n(8);class i{static scanDocument(e){let t=null;const n=[];for(let r=0;r<e.lineCount;r++){const o=e.lineAt(r);if(o&&!o.isEmptyOrWhitespace)if(o.text.startsWith("<<<<<<<")){if(null!==t){t=null;break}t={startHeader:o,commonAncestors:[]}}else if(t&&!t.splitter&&o.text.startsWith("|||||||"))t.commonAncestors.push(o);else if(t&&!t.splitter&&"======="===o.text)t.splitter=o;else if(t&&o.text.startsWith(">>>>>>>")){t.endFooter=o;let r=i.scanItemTolMergeConflictDescriptor(e,t);null!==r&&n.push(r),t=null}}return n.filter(Boolean).map(e=>new o.DocumentMergeConflict(e))}static scanItemTolMergeConflictDescriptor(e,t){if(!t.startHeader||!t.splitter||!t.endFooter)return null;let n=t.commonAncestors[0]||t.splitter;return{current:{header:t.startHeader.range,decoratorContent:new r.Range(t.startHeader.rangeIncludingLineBreak.end,i.shiftBackOneCharacter(e,n.range.start,t.startHeader.rangeIncludingLineBreak.end)),content:new r.Range(t.startHeader.rangeIncludingLineBreak.end,n.range.start),name:t.startHeader.text.substring("<<<<<<<".length+1)},commonAncestors:t.commonAncestors.map((n,o,s)=>{let a=s[o+1]||t.splitter;return{header:n.range,decoratorContent:new r.Range(n.rangeIncludingLineBreak.end,i.shiftBackOneCharacter(e,a.range.start,n.rangeIncludingLineBreak.end)),content:new r.Range(n.rangeIncludingLineBreak.end,a.range.start),name:n.text.substring("|||||||".length+1)}}),splitter:t.splitter.range,incoming:{header:t.endFooter.range,decoratorContent:new r.Range(t.splitter.rangeIncludingLineBreak.end,i.shiftBackOneCharacter(e,t.endFooter.range.start,t.splitter.rangeIncludingLineBreak.end)),content:new r.Range(t.splitter.rangeIncludingLineBreak.end,t.endFooter.range.start),name:t.endFooter.text.substring(">>>>>>>".length+1)},range:new r.Range(t.startHeader.range.start,t.endFooter.rangeIncludingLineBreak.end)}}static containsConflict(e){if(!e)return!1;let t=e.getText();return t.includes("<<<<<<<")&&t.includes(">>>>>>>")}static shiftBackOneCharacter(e,t,n){if(t.isEqual(n))return t;let o=t.line,i=t.character-1;return i<0&&(o--,i=e.lineAt(o).range.end.character),new r.Position(o,i)}}t.MergeConflictParser=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DocumentMergeConflict=void 0;t.DocumentMergeConflict=class{constructor(e){this.range=e.range,this.current=e.current,this.incoming=e.incoming,this.commonAncestors=e.commonAncestors,this.splitter=e.splitter}commitEdit(e,t,n){return n?(this.applyEdit(e,t.document,n),Promise.resolve(!0)):t.edit(n=>this.applyEdit(e,t.document,n))}applyEdit(e,t,n){if(0===e){let e=t.getText(this.current.content);this.replaceRangeWithContent(e,n)}else if(1===e){let e=t.getText(this.incoming.content);this.replaceRangeWithContent(e,n)}else if(2===e){const e=t.getText(this.current.content),r=t.getText(this.incoming.content);n.replace(this.range,e.concat(r))}}replaceRangeWithContent(e,t){this.isNewlineOnly(e)?t.replace(this.range,""):t.replace(this.range,e)}isNewlineOnly(e){return"\n"===e||"\r\n"===e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Delayer=void 0;t.Delayer=class{constructor(e){this.defaultDelay=e,this.timeout=null,this.completionPromise=null,this.onSuccess=null,this.task=null}trigger(e,t=this.defaultDelay){return this.task=e,t>=0&&this.cancelTimeout(),this.completionPromise||(this.completionPromise=new Promise(e=>{this.onSuccess=e}).then(()=>{this.completionPromise=null,this.onSuccess=null;let e=this.task();return this.task=null,e})),(t>=0||null===this.timeout)&&(this.timeout=setTimeout(()=>{this.timeout=null,this.onSuccess(void 0)},t>=0?t:this.defaultDelay)),this.completionPromise}forceDelivery(){if(!this.completionPromise)return null;this.cancelTimeout();let e=this.completionPromise;return this.onSuccess(void 0),e}isTriggered(){return null!==this.timeout}cancel(){this.cancelTimeout(),this.completionPromise=null}cancelTimeout(){null!==this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0),o=n(2).loadMessageBundle(n(1).join(__dirname,"codelensProvider.ts"));t.default=class{constructor(e){this.tracker=e.createTracker("codelens")}begin(e){this.config=e,this.config.enableCodeLens&&this.registerCodeLensProvider()}configurationUpdated(e){!1===e.enableCodeLens&&this.codeLensRegistrationHandle?(this.codeLensRegistrationHandle.dispose(),this.codeLensRegistrationHandle=null):!0!==e.enableCodeLens||this.codeLensRegistrationHandle||this.registerCodeLensProvider(),this.config=e}dispose(){this.codeLensRegistrationHandle&&(this.codeLensRegistrationHandle.dispose(),this.codeLensRegistrationHandle=null)}async provideCodeLenses(e,t){var n;if(!this.config||!this.config.enableCodeLens)return null;let i=await this.tracker.getConflicts(e);const s=null!==(n=null==i?void 0:i.length)&&void 0!==n?n:0;if(r.commands.executeCommand("setContext","mergeConflictsCount",s),!s)return null;let a=[];return i.forEach(e=>{let t={command:"merge-conflict.accept.current",title:o(0,null),arguments:["known-conflict",e]},n={command:"merge-conflict.accept.incoming",title:o(1,null),arguments:["known-conflict",e]},i={command:"merge-conflict.accept.both",title:o(2,null),arguments:["known-conflict",e]},s={command:"merge-conflict.compare",title:o(3,null),arguments:[e]};a.push(new r.CodeLens(e.range,t),new r.CodeLens(e.range.with(e.range.start.with({character:e.range.start.character+1})),n),new r.CodeLens(e.range.with(e.range.start.with({character:e.range.start.character+2})),i),new r.CodeLens(e.range.with(e.range.start.with({character:e.range.start.character+3})),s))}),a}registerCodeLensProvider(){this.codeLensRegistrationHandle=r.languages.registerCodeLensProvider([{scheme:"file"},{scheme:"vscode-vfs"},{scheme:"untitled"},{scheme:"vscode-userdata"}],this)}}},function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0),o=n(3),i=n(2).loadMessageBundle(n(1).join(__dirname,"commandHandler.ts"));var s;!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(s||(s={}));t.default=class{constructor(e){this.disposables=[],this.tracker=e.createTracker("commands")}begin(){this.disposables.push(this.registerTextEditorCommand("merge-conflict.accept.current",this.acceptCurrent),this.registerTextEditorCommand("merge-conflict.accept.incoming",this.acceptIncoming),this.registerTextEditorCommand("merge-conflict.accept.selection",this.acceptSelection),this.registerTextEditorCommand("merge-conflict.accept.both",this.acceptBoth),this.registerTextEditorCommand("merge-conflict.accept.all-current",this.acceptAllCurrent,this.acceptAllCurrentResources),this.registerTextEditorCommand("merge-conflict.accept.all-incoming",this.acceptAllIncoming,this.acceptAllIncomingResources),this.registerTextEditorCommand("merge-conflict.accept.all-both",this.acceptAllBoth),this.registerTextEditorCommand("merge-conflict.next",this.navigateNext),this.registerTextEditorCommand("merge-conflict.previous",this.navigatePrevious),this.registerTextEditorCommand("merge-conflict.compare",this.compare))}registerTextEditorCommand(e,t,n){return r.commands.registerCommand(e,(...e)=>{if(n&&e.length&&e.every(e=>e&&e.resourceUri))return n.call(this,e.map(e=>e.resourceUri));const o=r.window.activeTextEditor;return o&&t.call(this,o,...e)})}acceptCurrent(e,...t){return this.accept(0,e,...t)}acceptIncoming(e,...t){return this.accept(1,e,...t)}acceptBoth(e,...t){return this.accept(2,e,...t)}acceptAllCurrent(e){return this.acceptAll(0,e)}acceptAllIncoming(e){return this.acceptAll(1,e)}acceptAllCurrentResources(e){return this.acceptAllResources(0,e)}acceptAllIncomingResources(e){return this.acceptAllResources(1,e)}acceptAllBoth(e){return this.acceptAll(2,e)}async compare(e,t){if(!t&&!(t=await this.findConflictContainingSelection(e)))return void r.window.showWarningMessage(i(0,null));const n=await this.tracker.getConflicts(e.document);if(!n)return void r.window.showWarningMessage(i(1,null));const s=e.document.uri.scheme;let a=t.current.content,c=n.map(e=>[e.current.content,e.range]),l=n.map(e=>[e.incoming.content,e.range]);const u=e.document.uri.with({scheme:o.default.scheme,query:JSON.stringify({scheme:s,range:a,ranges:c})});a=t.incoming.content;const d=u.with({query:JSON.stringify({scheme:s,ranges:l})});let g=0;for(let e of n){if(e.range.isEqual(t.range))break;g+=e.range.end.line-e.range.start.line-(e.incoming.content.end.line-e.incoming.content.start.line)}const h=new r.Range(t.range.start.line-g,t.range.start.character,t.range.start.line-g,t.range.start.character),f=e.document.uri.path,m=f.substring(f.lastIndexOf("/")+1),p=i(2,null,m),w=r.workspace.getConfiguration("merge-conflict").get("diffViewPosition"),v={viewColumn:"Beside"===w?r.ViewColumn.Beside:r.ViewColumn.Active,selection:h};"Below"===w&&await r.commands.executeCommand("workbench.action.newGroupBelow"),await r.commands.executeCommand("vscode.diff",u,d,p,v)}navigateNext(e){return this.navigate(e,s.Forwards)}navigatePrevious(e){return this.navigate(e,s.Backwards)}async acceptSelection(e){let t,n=await this.findConflictContainingSelection(e);if(!n)return void r.window.showWarningMessage(i(3,null));let o=n.splitter;if(n.commonAncestors.length>0&&(o=n.commonAncestors[0].header),e.selection.active.isBefore(o.start))t=0;else{if(!e.selection.active.isAfter(n.splitter.end))return e.selection.active.isBefore(n.splitter.start)?void r.window.showWarningMessage(i(4,null)):void r.window.showWarningMessage(i(5,null));t=1}this.tracker.forget(e.document),n.commitEdit(t,e)}dispose(){this.disposables.forEach(e=>e.dispose()),this.disposables=[]}async navigate(e,t){let n=await this.findConflictForNavigation(e,t);if(n)n.canNavigate?n.conflict&&(e.selection=new r.Selection(n.conflict.range.start,n.conflict.range.start),e.revealRange(n.conflict.range,r.TextEditorRevealType.Default)):r.window.showWarningMessage(i(7,null));else{if(r.workspace.getConfiguration("merge-conflict").get("autoNavigateNextConflict.enabled"))return;r.window.showWarningMessage(i(6,null))}}async accept(e,t,...n){let o;if(o="known-conflict"===n[0]?n[1]:await this.findConflictContainingSelection(t),!o)return void r.window.showWarningMessage(i(8,null));this.tracker.forget(t.document),o.commitEdit(e,t);r.workspace.getConfiguration("merge-conflict").get("autoNavigateNextConflict.enabled")&&this.navigateNext(t)}async acceptAll(e,t){let n=await this.tracker.getConflicts(t.document);n&&0!==n.length?(this.tracker.forget(t.document),await t.edit(r=>n.forEach(n=>{n.applyEdit(e,t.document,r)}))):r.window.showWarningMessage(i(9,null))}async acceptAllResources(e,t){const n=await Promise.all(t.map(e=>r.workspace.openTextDocument(e))),o=new r.WorkspaceEdit;for(const t of n){const n=await this.tracker.getConflicts(t);n&&0!==n.length&&(this.tracker.forget(t),n.forEach(n=>{n.applyEdit(e,t,{replace:(e,n)=>o.replace(t.uri,e,n)})}))}r.workspace.applyEdit(o)}async findConflictContainingSelection(e,t){if(t||(t=await this.tracker.getConflicts(e.document)),!t||0===t.length)return null;for(const n of t)if(n.range.contains(e.selection.active))return n;return null}async findConflictForNavigation(e,t,n){if(n||(n=await this.tracker.getConflicts(e.document)),!n||0===n.length)return null;let r,o,i,a=e.selection.active;if(1===n.length)return n[0].range.contains(a)?{canNavigate:!1}:{canNavigate:!0,conflict:n[0]};if(t===s.Forwards)r=e=>a.isBefore(e.range.start),o=()=>n[0],i=n;else{if(t!==s.Backwards)throw new Error("Unsupported direction "+t);r=e=>a.isAfter(e.range.start),o=()=>n[n.length-1],i=n.slice().reverse()}for(const e of i)if(r(e)&&!e.range.contains(a))return{canNavigate:!0,conflict:e};return{canNavigate:!0,conflict:o()}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0),o=n(2).loadMessageBundle(n(1).join(__dirname,"mergeDecorator.ts"));t.default=class{constructor(e,t){this.context=e,this.decorations={},this.decorationUsesWholeLine=!0,this.updating=new Map,this.tracker=t.createTracker("decorator")}begin(e){this.config=e,this.registerDecorationTypes(e),r.window.visibleTextEditors.forEach(e=>this.applyDecorations(e)),r.workspace.onDidOpenTextDocument(e=>{this.applyDecorationsFromEvent(e)},null,this.context.subscriptions),r.workspace.onDidChangeTextDocument(e=>{this.applyDecorationsFromEvent(e.document)},null,this.context.subscriptions),r.window.onDidChangeVisibleTextEditors(e=>{e.forEach(e=>this.applyDecorations(e))},null,this.context.subscriptions)}configurationUpdated(e){this.config=e,this.registerDecorationTypes(e),r.window.visibleTextEditors.forEach(e=>{this.removeDecorations(e),this.applyDecorations(e)})}registerDecorationTypes(e){Object.keys(this.decorations).forEach(e=>this.decorations[e].dispose()),this.decorations={},e.enableDecorations&&e.enableEditorOverview&&((e.enableDecorations||e.enableEditorOverview)&&(this.decorations["current.content"]=r.window.createTextEditorDecorationType(this.generateBlockRenderOptions("merge.currentContentBackground","editorOverviewRuler.currentContentForeground",e)),this.decorations["incoming.content"]=r.window.createTextEditorDecorationType(this.generateBlockRenderOptions("merge.incomingContentBackground","editorOverviewRuler.incomingContentForeground",e)),this.decorations["commonAncestors.content"]=r.window.createTextEditorDecorationType(this.generateBlockRenderOptions("merge.commonContentBackground","editorOverviewRuler.commonContentForeground",e))),e.enableDecorations&&(this.decorations["current.header"]=r.window.createTextEditorDecorationType({isWholeLine:this.decorationUsesWholeLine,backgroundColor:new r.ThemeColor("merge.currentHeaderBackground"),color:new r.ThemeColor("editor.foreground"),outlineStyle:"solid",outlineWidth:"1pt",outlineColor:new r.ThemeColor("merge.border"),after:{contentText:" "+o(0,null),color:new r.ThemeColor("descriptionForeground")}}),this.decorations["commonAncestors.header"]=r.window.createTextEditorDecorationType({isWholeLine:this.decorationUsesWholeLine,backgroundColor:new r.ThemeColor("merge.commonHeaderBackground"),color:new r.ThemeColor("editor.foreground"),outlineStyle:"solid",outlineWidth:"1pt",outlineColor:new r.ThemeColor("merge.border")}),this.decorations.splitter=r.window.createTextEditorDecorationType({color:new r.ThemeColor("editor.foreground"),outlineStyle:"solid",outlineWidth:"1pt",outlineColor:new r.ThemeColor("merge.border"),isWholeLine:this.decorationUsesWholeLine}),this.decorations["incoming.header"]=r.window.createTextEditorDecorationType({backgroundColor:new r.ThemeColor("merge.incomingHeaderBackground"),color:new r.ThemeColor("editor.foreground"),outlineStyle:"solid",outlineWidth:"1pt",outlineColor:new r.ThemeColor("merge.border"),isWholeLine:this.decorationUsesWholeLine,after:{contentText:" "+o(1,null),color:new r.ThemeColor("descriptionForeground")}})))}dispose(){Object.keys(this.decorations).forEach(e=>{this.decorations[e].dispose()}),this.decorations={}}generateBlockRenderOptions(e,t,n){let o={};return n.enableDecorations&&(o.backgroundColor=new r.ThemeColor(e),o.isWholeLine=this.decorationUsesWholeLine),n.enableEditorOverview&&(o.overviewRulerColor=new r.ThemeColor(t),o.overviewRulerLane=r.OverviewRulerLane.Full),o}applyDecorationsFromEvent(e){for(const t of r.window.visibleTextEditors)t.document===e&&this.applyDecorations(t)}async applyDecorations(e){if(e&&e.document&&this.config&&(this.config.enableDecorations||this.config.enableEditorOverview)&&!this.updating.get(e))try{this.updating.set(e,!0);let t=await this.tracker.getConflicts(e.document);if(-1===r.window.visibleTextEditors.indexOf(e))return;if(0===t.length)return void this.removeDecorations(e);let n={},o=(e,t)=>{n[e]=n[e]||[],n[e].push(t)};t.forEach(e=>{e.current.decoratorContent.isEmpty||o("current.content",e.current.decoratorContent),e.incoming.decoratorContent.isEmpty||o("incoming.content",e.incoming.decoratorContent),e.commonAncestors.forEach(e=>{e.decoratorContent.isEmpty||o("commonAncestors.content",e.decoratorContent)}),this.config.enableDecorations&&(o("current.header",e.current.header),o("splitter",e.splitter),o("incoming.header",e.incoming.header),e.commonAncestors.forEach(e=>{o("commonAncestors.header",e.header)}))}),Object.keys(n).forEach(t=>{let r=this.decorations[t];r&&e.setDecorations(r,n[t])})}finally{this.updating.delete(e)}}removeDecorations(e){Object.keys(this.decorations).forEach(t=>{let n=this.decorations[t];n&&e.setDecorations(n,[])})}}}]));
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/undefined/extensions/merge-conflict/dist/mergeConflictMain.js.map