diff options
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/utils.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/main.js | 18 |
3 files changed, 9 insertions, 20 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index 59445afc7a4..0393f3859a9 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -5,7 +5,7 @@ import eventHub from '../../eventhub'; import service from '../../services'; import * as types from '../mutation_types'; import router from '../../ide_router'; -import { setPageTitle, replaceFileUrl } from '../utils'; +import { setPageTitle, replaceFileUrl, addFinalNewlineIfNeeded } from '../utils'; import { viewerTypes, stageKeys } from '../../constants'; export const closeFile = ({ commit, state, dispatch }, file) => { @@ -140,7 +140,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = export const changeFileContent = ({ commit, dispatch, state }, { path, content }) => { const file = state.entries[path]; - commit(types.UPDATE_FILE_CONTENT, { path, content }); + commit(types.UPDATE_FILE_CONTENT, { + path, + content: addFinalNewlineIfNeeded(content), + }); const indexOfChangedFile = state.changedFiles.findIndex(f => f.path === path); diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js index a8d8ff31afe..3ccb3722e6f 100644 --- a/app/assets/javascripts/ide/stores/utils.js +++ b/app/assets/javascripts/ide/stores/utils.js @@ -269,3 +269,7 @@ export const pathsAreEqual = (a, b) => { return cleanA === cleanB; }; + +// if the contents of a file dont end with a newline, this function adds a newline +export const addFinalNewlineIfNeeded = content => + content.charAt(content.length - 1) !== '\n' ? `${content}\n` : content; diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 007eecdd293..465c9a362ba 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -160,24 +160,6 @@ function deferredInitialisation() { }); loadAwardsHandler(); - - /** - * Toggle Canary Badge - * - * For GitLab.com only, when the user is using canary - * we render a Next badge and hide the option to switch - * to canay - */ - if (Cookies.get('gitlab_canary') && Cookies.get('gitlab_canary') === 'true') { - const canaryBadge = document.querySelector('.js-canary-badge'); - const canaryLink = document.querySelector('.js-canary-link'); - if (canaryBadge) { - canaryBadge.classList.remove('hidden'); - } - if (canaryLink) { - canaryLink.classList.add('hidden'); - } - } } document.addEventListener('DOMContentLoaded', () => { |